可捕获的致命错误:php json解码

My json data

{
  "total": 533489,
  "page": 1,
  "pagesize": 30,
  "questions": [
    {
      "tags": [
        "php",
        "html",
        "forms"
      ],
      "answer_count": 6,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075370/timeline",
      "question_comments_url": "/questions/22075370/comments",
      "question_answers_url": "/questions/22075370/answers",
      "question_id": 22075370,
      "owner": {
        "user_id": 3343981,
        "user_type": "registered",
        "display_name": "user3343981",
        "reputation": 3,
        "email_hash": "55d0eb4577a0ba9f9e428d445431b595"
      },
      "creation_date": 1393520772,
      "last_activity_date": 1393522799,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 48,
      "score": 0,
      "community_owned": false,
      "title": "Issues with my form"
    },
    {
      "tags": [
        "php",
        "arrays"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22076141/timeline",
      "question_comments_url": "/questions/22076141/comments",
      "question_answers_url": "/questions/22076141/answers",
      "question_id": 22076141,
      "owner": {
        "user_id": 1479092,
        "user_type": "registered",
        "display_name": "Waldermort",
        "reputation": 470,
        "email_hash": "a00b970322ae60986ca4ed7629c7389b"
      },
      "creation_date": 1393522754,
      "last_activity_date": 1393522754,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 12,
      "score": 0,
      "community_owned": false,
      "title": "How to find the first free key in an array"
    },
    {
      "tags": [
        "php",
        "codeigniter",
        "postgresql"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22076140/timeline",
      "question_comments_url": "/questions/22076140/comments",
      "question_answers_url": "/questions/22076140/answers",
      "question_id": 22076140,
      "owner": {
        "user_id": 3220020,
        "user_type": "registered",
        "display_name": "Kino",
        "reputation": 18,
        "email_hash": "839332924b8b9e3fdbc1465690378aa2"
      },
      "creation_date": 1393522752,
      "last_activity_date": 1393522752,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 3,
      "score": 0,
      "community_owned": false,
      "title": "multiply 2 values from different table using codeigniter and postgresql foreach()"
    },
    {
      "tags": [
        "php"
      ],
      "answer_count": 1,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22076037/timeline",
      "question_comments_url": "/questions/22076037/comments",
      "question_answers_url": "/questions/22076037/answers",
      "question_id": 22076037,
      "owner": {
        "user_id": 2719411,
        "user_type": "registered",
        "display_name": "Xander",
        "reputation": 12,
        "email_hash": "66a15843818fbcbc6aa01c19ec62aed0"
      },
      "creation_date": 1393522498,
      "last_activity_date": 1393522735,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 24,
      "score": 0,
      "community_owned": false,
      "title": "Hide div based on time - PHP"
    },
    {
      "tags": [
        "php",
        ".htaccess",
        "ping",
        "password-protection"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22076119/timeline",
      "question_comments_url": "/questions/22076119/comments",
      "question_answers_url": "/questions/22076119/answers",
      "question_id": 22076119,
      "owner": {
        "user_id": 3361650,
        "user_type": "registered",
        "display_name": "user3361650",
        "reputation": 1,
        "email_hash": "84fd66f3c92515f9d2a45a2ca507a0ab"
      },
      "creation_date": 1393522695,
      "last_activity_date": 1393522695,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 8,
      "score": 0,
      "community_owned": false,
      "title": "How to check website is online if it is password protected"
    },
    {
      "tags": [
        "php",
        "string",
        "random"
      ],
      "answer_count": 2,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075958/timeline",
      "question_comments_url": "/questions/22075958/comments",
      "question_answers_url": "/questions/22075958/answers",
      "question_id": 22075958,
      "owner": {
        "user_id": 1573630,
        "user_type": "registered",
        "display_name": "Michal S",
        "reputation": 157,
        "email_hash": "05e9ad26aa0851931b7cca5f130ac081"
      },
      "creation_date": 1393522296,
      "last_edit_date": 1393522474,
      "last_activity_date": 1393522685,
      "up_vote_count": 1,
      "down_vote_count": 0,
      "view_count": 24,
      "score": 1,
      "community_owned": false,
      "title": "PHP - How to select random tag in the string"
    },
    {
      "tags": [
        "php",
        "symfony2",
        "symfony-forms"
      ],
      "answer_count": 1,
      "accepted_answer_id": 22076109,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075054/timeline",
      "question_comments_url": "/questions/22075054/comments",
      "question_answers_url": "/questions/22075054/answers",
      "question_id": 22075054,
      "owner": {
        "user_id": 245552,
        "user_type": "registered",
        "display_name": "Matthieu Napoli",
        "reputation": 7586,
        "email_hash": "48906ce482893497d2d7e017cd2f4352"
      },
      "creation_date": 1393519990,
      "last_activity_date": 1393522680,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 9,
      "score": 0,
      "community_owned": false,
      "title": "Symfony form: customize the setter that is called"
    },
    {
      "tags": [
        "php",
        "wordpress",
        "sorting"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22076089/timeline",
      "question_comments_url": "/questions/22076089/comments",
      "question_answers_url": "/questions/22076089/answers",
      "question_id": 22076089,
      "owner": {
        "user_id": 2279387,
        "user_type": "registered",
        "display_name": "Tomas Kleinotas",
        "reputation": 7,
        "email_hash": "6ba9fc650c619efae62691c8456ca76f"
      },
      "creation_date": 1393522645,
      "last_activity_date": 1393522645,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 3,
      "score": 0,
      "community_owned": false,
      "title": "How to sort category posts by meta_value if there are empty fields?"
    },
    {
      "tags": [
        "php",
        "mysql",
        "pdf",
        "embed",
        "blob"
      ],
      "answer_count": 1,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075847/timeline",
      "question_comments_url": "/questions/22075847/comments",
      "question_answers_url": "/questions/22075847/answers",
      "question_id": 22075847,
      "owner": {
        "user_id": 3346480,
        "user_type": "registered",
        "display_name": "Richard",
        "reputation": 1,
        "email_hash": "40e5ef3a529b8b66ec994c2b6a1d1555"
      },
      "creation_date": 1393522007,
      "last_activity_date": 1393522615,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 3,
      "score": 0,
      "community_owned": false,
      "title": "embed pdf from blob to html/php page"
    },
    {
      "tags": [
        "php"
      ],
      "answer_count": 2,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075599/timeline",
      "question_comments_url": "/questions/22075599/comments",
      "question_answers_url": "/questions/22075599/answers",
      "question_id": 22075599,
      "owner": {
        "user_id": 3361419,
        "user_type": "registered",
        "display_name": "Eduardo",
        "reputation": 1,
        "email_hash": "e3561abf3d1b9969686df7113a4d82f6"
      },
      "creation_date": 1393521373,
      "last_activity_date": 1393522615,
      "up_vote_count": 0,
      "down_vote_count": 6,
      "view_count": 16,
      "score": -6,
      "community_owned": false,
      "title": "Parse syntax error, unexpected end of file in C:\\xampp\\htdocs\\Pap\\create.php on line 292"
    },
    {
      "tags": [
        "php",
        "forms",
        "checkbox",
        "tcpdf"

    {
      "tags": [
        "php",
        "composer-php",
        "directory-structure",
        "laravel-4.1"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075957/timeline",
      "question_comments_url": "/questions/22075957/comments",
      "question_answers_url": "/questions/22075957/answers",
      "question_id": 22075957,
      "owner": {
        "user_id": 1202367,
        "user_type": "registered",
        "display_name": "Claudio Ludovico Panetta",
        "reputation": 393,
        "email_hash": "2dca89fe809118d3a93d5a51e2cd28bd"
      },
      "creation_date": 1393522295,
      "last_activity_date": 1393522295,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 5,
      "score": 0,
      "community_owned": false,
      "title": "Centralize vendor folder in Laravel 4.1.x"
    },
    {
      "tags": [
        "php",
        "sms"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075948/timeline",
      "question_comments_url": "/questions/22075948/comments",
      "question_answers_url": "/questions/22075948/answers",
      "question_id": 22075948,
      "owner": {
        "user_id": 3333903,
        "user_type": "registered",
        "display_name": "ArpanTechBuddy",
        "reputation": 1,
        "email_hash": "2abb3673c9cca94de81942f3b0b0488b"
      },
      "creation_date": 1393522276,
      "last_activity_date": 1393522276,
      "up_vote_count": 0,
      "down_vote_count": 3,
      "view_count": 12,
      "score": -3,
      "community_owned": false,
      "title": "SMS from PHP to any number for free"
    },
    {
      "tags": [
        "php",
        "curl"
      ],
      "answer_count": 4,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075803/timeline",
      "question_comments_url": "/questions/22075803/comments",
      "question_answers_url": "/questions/22075803/answers",
      "question_id": 22075803,
      "owner": {
        "user_id": 1459253,
        "user_type": "registered",
        "display_name": "Siddesh Bhalke",
        "reputation": 671,
        "email_hash": "262597fd50cb34b6ddbc168b8f2d77a5"
      },
      "creation_date": 1393521922,
      "last_activity_date": 1393522259,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 9,
      "score": 0,
      "community_owned": false,
      "title": "curl_init() has been disabled for security reasons"
    },
    {
      "tags": [
        "php",
        "wordpress",
        "rewrite"
      ],
      "answer_count": 2,
      "favorite_count": 0,
      "question_timeline_url": "/questions/18602715/timeline",
      "question_comments_url": "/questions/18602715/comments",
      "question_answers_url": "/questions/18602715/answers",
      "question_id": 18602715,
      "owner": {
        "user_id": 648938,
        "user_type": "registered",
        "display_name": "Scrooby",
        "reputation": 2164,
        "email_hash": "f280a3e68d054f94c2afa52c950a40b9"
      },
      "creation_date": 1378248631,
      "last_edit_date": 1393521961,
      "last_activity_date": 1393522236,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 116,
      "score": 0,
      "community_owned": false,
      "title": "Page Not Found in title of WordPress page on template_redirect using include()"
    },
    {
      "tags": [
        "php",
        "mysql",
        "database-design"
      ],
      "answer_count": 1,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075748/timeline",
      "question_comments_url": "/questions/22075748/comments",
      "question_answers_url": "/questions/22075748/answers",
      "question_id": 22075748,
      "owner": {
        "user_id": 741156,
        "user_type": "registered",
        "display_name": "Momen M El Zalabany",
        "reputation": 957,
        "email_hash": "6819dd0de162410dcccd7b1b03bb5def"
      },
      "creation_date": 1393521798,
      "last_edit_date": 1393522196,
      "last_activity_date": 1393522196,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 14,
      "score": 0,
      "community_owned": false,
      "title": "mysql design for employees working hours"
    },
    {
      "tags": [
        "php",
        "logging",
        "controller",
        "event-handling",
        "zend-framework2"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075903/timeline",
      "question_comments_url": "/questions/22075903/comments",
      "question_answers_url": "/questions/22075903/answers",
      "question_id": 22075903,
      "owner": {
        "user_id": 928044,
        "user_type": "registered",
        "display_name": "Vincent Caggiari",
        "reputation": 8,
        "email_hash": "3779e0b7d9bebe76c674bd59fa7016e9"
      },
      "creation_date": 1393522170,
      "last_activity_date": 1393522170,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 4,
      "score": 0,
      "community_owned": false,
      "title": "zend 2 event manager wildcard + keywords"
    },
    {
      "tags": [
        "php",
        "wordpress"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075764/timeline",
      "question_comments_url": "/questions/22075764/comments",
      "question_answers_url": "/questions/22075764/answers",
      "question_id": 22075764,
      "owner": {
        "user_id": 1469270,
        "user_type": "registered",
        "display_name": "tmyie",
        "reputation": 515,
        "email_hash": "c7522e105f49699af313a6aba52a66bc"
      },
      "creation_date": 1393521834,
      "last_edit_date": 1393522153,
      "last_activity_date": 1393522153,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 17,
      "score": 0,
      "community_owned": false,
      "title": "Loop through all posts, show attachment if there (WordPress)"
    },
    {
      "tags": [
        "php",
        "api",
        "paypal",
        "express",
        "checkout"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22074086/timeline",
      "question_comments_url": "/questions/22074086/comments",
      "question_answers_url": "/questions/22074086/answers",
      "question_id": 22074086,
      "owner": {
        "user_id": 3361211,
        "user_type": "registered",
        "display_name": "PmLvgn",
        "reputation": 1,
        "email_hash": "a4df4e1cb22b77c2e898d791c117a3a5"
      },
      "creation_date": 1393517599,
      "last_edit_date": 1393522102,
      "last_activity_date": 1393522102,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 8,
      "score": 0,
      "community_owned": false,
      "title": "PHP Paypal API ExpressCheckout, i don't know what i sold in history details"
    },
    {
      "tags": [
        "php",
        "braintree"
      ],
      "answer_count": 1,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22056863/timeline",
      "question_comments_url": "/questions/22056863/comments",
      "question_answers_url": "/questions/22056863/answers",
      "question_id": 22056863,
      "owner": {
        "user_id": 1233455,
        "user_type": "registered",
        "display_name": "JasonMortonNZ",
        "reputation": 967,
        "email_hash": "1d2bc25a4d7db82dd86c411afda88e8f"
      },
      "creation_date": 1393462513,
      "last_activity_date": 1393522017,
      "up_vote_count": 1,
      "down_vote_count": 0,
      "view_count": 12,
      "score": 1,
      "community_owned": false,
      "title": "Braintree API in PHP success and currency issue"
    },
    {
      "tags": [
        "php"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075831/timeline",
      "question_comments_url": "/questions/22075831/comments",
      "question_answers_url": "/questions/22075831/answers",
      "question_id": 22075831,
      "owner": {
        "user_id": 3282713,
        "user_type": "registered",
        "display_name": "user3282713",
        "reputation": 1,
        "email_hash": "0fdeb1c7e8da488a6556ccc8386d0249"
      },
      "creation_date": 1393521988,
      "last_activity_date": 1393521988,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 6,
      "score": 0,
      "community_owned": false,
      "title": "updating multiple items through checkbox in php"
    },
    {
      "tags": [
        "php",
        "html"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/22075634/timeline",
      "question_comments_url": "/questions/22075634/comments",
      "question_answers_url": "/questions/22075634/answers",
      "question_id": 22075634,
      "owner": {
        "user_id": 2640557,
        "user_type": "registered",
        "display_name": "aveleon",
        "reputation": 20,
        "email_hash": "b20903bea6646401a4d88a7852ae6229"
      },
      "creation_date": 1393521474,
      "last_edit_date": 1393521949,
      "last_activity_date": 1393521949,
      "up_vote_count": 1,
      "down_vote_count": 1,
      "view_count": 44,
      "score": 0,
      "community_owned": false,
      "title": "PHP is not working and cannot find out why (creating dynamic content)"
    },
    {
      "tags": [
        "php",
        "android",
        "web-services",
        "mobile",
        "service"
      ],
      "answer_count": 1,
      "favorite_count": 1,
      "closed_date": 1393520310,
      "closed_reason": "primarily opinion-based",
      "question_timeline_url": "/questions/22075094/timeline",
      "question_comments_url": "/questions/22075094/comments",
      "question_answers_url": "/questions/22075094/answers",
      "question_id": 22075094,
      "owner": {
        "user_id": 2715065,
        "user_type": "registered",
        "display_name": "Warde",
        "reputation": 285,
        "email_hash": "f265910523dec1dc1e11bb02b4af79a5"
      },
      "creation_date": 1393520062,
      "last_edit_date": 1393521803,
      "last_activity_date": 1393521803,
      "up_vote_count": 0,
      "down_vote_count": 9,
      "view_count": 35,
      "score": -9,
      "community_owned": false,
      "title": "Need a service that sends the complete information of contacts to the server"
    }
  ]
}

Getting below error when i try json_decode('abovedata'),

ERROR:

Catchable fatal error: Object of class stdClass could not be converted to string in F:\xamp\htdocs\xampp\curl.php on line 12

How can i read each key values from above json data ?

dtd58256
dtd58256 你的json无效。使用jslint.com验证你的json
6 年多之前 回复
doulu4976
doulu4976 第12行是什么?json_decode返回一个对象(类stdClass),你可能会尝试将它用作一个字符串(通过echo,也许)
6 年多之前 回复

2个回答



试试这个.. </ p>

  json_decode($ data,true); 
</ code> </ pre>
</ div>

展开原文

原文

Try this..

json_decode($data,true);

dqh1984
dqh1984 问题是你不能使用谷歌..:P:P
6 年多之前 回复
duanchao4445
duanchao4445 ::完美有效,但我可能知道这是什么问题?
6 年多之前 回复



您的JSON无效,这就是函数未正确处理的原因。</ p>

 <  code>“tags”:[
“php”,
“forms”,
“复选框”,
“tcpdf”
</ code> </ pre>

看看这个 在这里,你永远不要关闭“标签”中的[]。 我使用了这个JSON验证器 </ p>
</ div>

展开原文

原文

Your JSON is invalid, that is why the function is not processing it correctly.

    "tags": [
    "php",
    "forms",
    "checkbox",
    "tcpdf"

Look at this section here, you never close the [] in "tags". I used this JSON validator

duanhuren5581
duanhuren5581 抱歉,我删除了几行json,因为Stackoverflown的正文部分不允许我添加这么冗长的代码。 但我担心这个错误。
6 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问