2015-01-05 14 views
2

我的json的結果是無效的。json中的html破json

的Json

{ 
    "item": { 
     "title": "Japanese investors back Lookup, a messaging app for local shopping in India", 
     "desc": "An infusion of US$116,000 from Japan's social games company DeNA and Teruhide Sato, founder of BEENOS, takes the three-month-old startup\u2019s seed funding to US$382,000.", 
     "link": "https:\/\/www.techinasia.com\/dena-teruhide-sato-beenos-fund-lookup\/", 
     "content": "<p><img src="https: \/\/www-techinasia.netdna-ssl.com\/wp-content\/uploads\/2015\/01\/lookup-app-main-720x289.jpg" alt="lookupappmain" width="720" height="289" class="aligncentersize-largewp-image-213938" \/><\/p>\n<p>Bangalore-based instant messaging app <a href="https: \/\/www.techinasia.com\/tag\/lookup\/">Lookup<\/a> – a Craiglist cum WhatsApp for local businesses – just got its third dose of seed funding. Japan&#8217;s leading social games company <a href="https: \/\/www.techinasia.com\/tag\/dena\/">DeNA<\/a> and Teruhide Sato, founder of BEENOS group, a global conglomerate with ecommerce holdings and a business incubator, invested US$116,000 into this three-month-old startup founded by Deepak Ravindran, a young serial entrepreneur.<\/p>\n<p>「Both our recent investors have strong footholds in the mobile space and have successfully led innovations in Japan,」 says Ravindran, suggesting that the investors would be giving Lookup more than just funding.<\/p>\n<p><a href="http: \/\/www.lookup.to">Lookup<\/a> lists businesses, restaurants, and even police stations for users to connect with. Unlike Craigslist or JustDial which would give you a number to dial, Lookup lets you shoot off a message to the local businesses without leaving the app. You can find prices and availability of products or services at local businesses, book appointments at salons, or make reservations at restaurants with this app. Any store or restaurant using Lookup can then respond instantly.<\/p>\n<p>Lookup has a call center tracking the messages to ensure that its users receive responses immediately, even if a store is not using the app. 「Our guarantee is that you get answers within five minutes. We do this by employing dedicated people for handling your request. Lookup’s call center fields your responses, calls up stores, and types answers back to you in real-time. No calling, no waiting,」 Ravindran told <em>Tech in Asia<\/em>.<\/p>\n<p>To celebrate the latest funding from Japanese investors, Lookup is gifting free sushi for a week to new users from Bangalore who download the app. For this, it has tied up with two Japanese restaurants Shiro and Ginseng.<\/p>\n<p>With this latest infusion, Lookup’s seed round of venture capital funding closed at US$382,000. It had earlier bagged US$166,000 from tech billionaire Kris Gopalakrishnan, co-founder of Indian IT bellwether Infosys, and US$100,000 from MKS Switzerland SA, a precious metals and financial services group of companies.<\/p>\n<p><center><strong>See: <a href="https: \/\/www.techinasia.com\/college-dropout-turned-mit-top-innovator-rolls-craigslist-whatsapp-app-local-shopping-india\/">College dropout turned MIT top innovator rolls Craigslist and WhatsApp into one app for local shopping in India<\/a><\/strong><\/center><\/p>\n<p>This post <a href="https: \/\/www.techinasia.com\/dena-teruhide-sato-beenos-fund-lookup\/" title="JapaneseinvestorsbackLookup, 
     amessagingappforlocalshoppinginIndia">Japanese investors back Lookup, a messaging app for local shopping in India<\/a> appeared first on Tech in Asia.<\/p>" 
    } 
} 

我的PHP

$arr = array(); 
$arr["item"]["content"] = htmlentities($content); // $content is dynamic, not fixed template. 
echo json_encode($arr); 

什麼來解決這個問題?

+4

你想要什麼?你的問題不清楚! –

+0

我第二。這個問題應該被擱置,直到它變得更加清晰。 – miestasmia

+0

@MustafaMJalal如何製作有效的json –

回答

0

http://php.net/manual/en/json.constants.php
json_encode($arr,true)
json_decode($arr,true)
使用試試這個

+0

仍然不能:http://i.imgur.com/8wfEikY.png –

+0

這個選項參數在PHP 5.3和更高版本中可用 –

+0

@NirajBurde我的PHP版本是5 –

0

嘗試逃脫雙引號addcslashes

$content = htmlentities($content); 
$arr["item"]["content"] = addcslashes($content,'"'); 
echo json_encode($arr); 
0

我認爲你需要做的是:

addslashes(htmlentities($content)); 

或者:

addcslashes(htmlentities($content), '"\\/'); 
+0

沒有人,產量變差 –