doukun8944 2015-01-05 07:57
浏览 51

无效的Json将html放入其中

I try to put html content within json, it broke.

My invalid Json http://i.imgur.com/8wfEikY.png

{
    "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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>"
    }
}

What I did in PHP

$arr = array();
$arr["item"]["content"] = $content; // $content is dynamic, scrapped from somewhere
echo json_encode($arr, true);

I tried htmlentities and addcslashes($item_content,'"') but nnoe of that work.

  • 写回答

2条回答 默认 最新

  • duanguan1573 2015-01-05 08:03
    关注

    It's because of the " sign in the image tag. You could use the HTML entities function to encode it en the decode function to decode it.

    A neater way to do it is to save the image url in a different property of your item.

    评论

报告相同问题?

悬赏问题

  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上