【问题标题】:Parse json object in php在 php 中解析 json 对象
【发布时间】:2014-08-28 13:55:29
【问题描述】:

json代码如下:

{"data":[
{"data":
{"created":"2014-02-26T21:14:56.662Z",
"district":"4fd43cc56d11340000000005",
"high_grade":"12",
"last_modified":"2014-02-26T21:14:56.665Z",
"location":{"address":"350 5th Avenue","city":"New York","state":"NY","zip":"10001"},
"low_grade":"9",
"name":"Clever High School",
"nces_id":"360008000000",
"phone":"(212) 555-1212",
"principal":{"name":"TheodoraKhan","email":"tdkhan@mailinator.com"},
"school_number":"02M800",
"sis_id":"02M800",
"state_id":"712345","id":"530e595026403103360ff9fd"},
"uri":"/v1.1/schools/530e595026403103360ff9fd"},

{"data":{"created":"2014-02-26T21:14:56.668Z","district":"4fd43cc56d11340000000005","high_grade":"5","last_modified":"2014-02-26T21:14:56.670Z","location":{"address":"110

菠萝 Street","city":"Brooklyn","state":"NY","zip":"11201"},"low_grade":"Kindergarten","name":"Clever 小学","nces_id":"360007000000","电话":"(718) 555-4567","校长":{"姓名":"塞西莉亚 罗德里克","email":"ceciliar@mailinator.com"},"school_number":"13K123","sis_id":"13K123","state_id":"30890","id":"530e595026403103360ff9fe"}," uri":"/v1.1/schools/530e595026403103360ff9fe"}

【问题讨论】:

标签: json


【解决方案1】:

我不太明白你在问什么。

但您可以使用以下内容:

$obj = json_decode($json_str);

【讨论】:

  • 如果不确定,为什么不作为评论询问并仅在您确定时才回答。这不就是stackoverflow吗?
  • @Nabin 这是一个措辞不当的问题,但我的回答是正确的。
【解决方案2】:

试试json_decode:

$data = {"data":"a"}:
$json = json_decode($data);
echo $json->data;

【讨论】:

    猜你喜欢
    • 2013-04-06
    • 2013-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 2018-07-28
    • 2015-07-16
    • 2014-04-05
    相关资源
    最近更新 更多