dqc2017 2011-07-30 19:18
浏览 113
已采纳

无法解析这个json

I am trying to parse the json output from

http://www.nyc.gov/portal/apps/311_contentapi/services/all.json

And my php json_decode returns a NULL

I am not sure where the issue is, I tried running a small subset of the data through JSONLint and it validated the json.

Any Ideas?

  • 写回答

3条回答 默认 最新

  • dsigg21445 2011-07-30 19:22
    关注

    The error is in this section:

    {
        "id":"2002-12-05-22-24-56_000010083df0188b4001eb56",
        "service_name":"Outdoor Electric System Complaint",
        "expiration":"2099-12-31T00:00:00Z",
        "brief_description":"Report faulty Con Edison equipment, including dangling or corroded power lines or "hot spots.""
    }
    

    See where it says "hot spots." in an already quoted string. Those "'s should've been escaped. Since you don't have access to edit the JSON perhaps you could do a search for "hot spots."" and replace it with \"hot spots.\"" like str_replace('"hot spots.""', '\\"hot spots.\\""\, $str); for as long as that's in there. Of course that only helps if this is a one time thing. If the site continues to make errors in their JSON output you'll have to come up with something more complex.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)