drxrgundk062317205 2013-10-29 16:47
浏览 38
已采纳

将curl响应解析为可读表

I sent a curl request to a server and get the following results:

{ "data": [
    { "state_msg": "Canceled", 
      "dpc": null, 
      "mgcp_call_ids": null, 
      "code": 487,"mgcp_mgc_ip": null, 
      "dst_codecs": "G729,telephone-event,H264,H263", 
      "megaco_mg_ip": null,"src_codecs": 
      "G729,PCMU,telephone-event,H264,H263", 
      "q850_state_details": null, 
      "pid":1383031680, 
      "call_time": null
.......

How can i parse this into readable fields? I am looking for something like foreach loop, or something similar.

if this were xml i could do

 $response->data->state_msg.  

Clearly that wont work here. what can i do?

  • 写回答

2条回答 默认 最新

  • doucan4815 2013-10-29 16:49
    关注

    That's a JSON response. Pass the string through json_decode to receive the object and iterate over it as you would any other object.

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分