How can it be wrong, a simple JSON read

Source: Internet
Author: User
$pingluninfo = <<
{
"title": "123",
"url": "Http://localhost/?p=9",
"Ttime": 1401327899094,
"SourceID": "9",
"ParentID": "0",
"CategoryID": "",
"ownerID": "",
"Metadata": "",
"Comments": [
{
"Cmtid": "358",
"CTime": 1401327899094,
"Content": "August 1, 2013 18:36:29 O (∩_∩) o~",
"Replyid": "0",
"User": {
"userid": "1",
"Nickname": "Admin",
"Usericon": "",
"Userurl": "",
"Usermetadata": {
"Area": "Beijing",
"Gender": "1",
"KK": "",
"Level": 1
}
},
"IP": "127.0.0.1",
"UserAgent": "mozilla/5.0 (Windows NT 6.1; rv:22.0) gecko/20100101 firefox/22.0 ",
"Channeltype": "1",
"From": "",
"Spcount": "",
"Opcount": "",
"Attachment": [
{
"Type": 1,
"desc": "",
"url": "Http://img.sohu.itc/xxxx"
}
]
}
]
}
EOT;

$pingluninfo = Json_decode ($pingluninfo, true);
if (! $pingluninfo) {
Die (' Wrong data format ');
}
?>
Always output the wrong data format


Reply to discussion (solution)

Look at the JSON is wrong.
Chinese is not like this after the Json_encode.

 ";p Rint_r ($pingluninfo); echo"
";

Output:
Array ([title] = 123 [url] = http://localhost/?p=9 [Ttime] = 1401327899094 [SourceID] + 9 [            ParentID] + 0 [CategoryID] = [ownerID] + [metadata] = [comments] = = Array (                     [0] = = Array ([Cmtid] = 358 [CTime] = 1401327899094 [Content] = August 1, 2013 18:36:29 O (∩_∩) o~ [Replyid] = 0 [US  ER] = Array ([userid] = 1 [nickname]                             = = admin [Usericon] [userurl] = =                                    [Usermetadata]/= Array ([area] = Beijing                                     [Gender] = 1 [KK] = [Level] = 1                                )) [IP] = 127.0.0.1 [use                    Ragent] = mozilla/5.0 (Windows NT 6.1; rv:22.0) gecko/20100101 firefox/22.0 [Channeltype] = 1                     [From] = [Spcount] [opcount] = =                                [Attachment] = = Array ([0] = = Array                                     ([Type] = 1 [desc] = =                [url] = http://img.sohu.itc/xxxx)) )        ))


Test error

Please enclose the quotation marks!
"Ttime": 1401327899094, should be "ttime": "1401327899094",
Other similar

Echo '
 
  
 '; $pingluninfo = <<
   
  
Tested, very normal.
([title] = 123 [url] = http://localhost/?p=9 [Ttime] = 1401327899094 [SourceID] + 9 [paren            TID] = 0 [CategoryID] = [ownerID] = [metadata] = [comments] + = Array (                    [0] = = Array ([Cmtid] = 358 [CTime] = 1401327899094 [Content] = August 1, 2013 18:36:29 O (∩_∩) o~ [Replyid] = 0 [user] = > Array ([userid] = 1 [nickname] =&gt ;                             admin [Usericon] = [Userurl] =                                    [Usermetadata]/= Array ([area] = Beijing                                     [Gender] = 1 [KK] =     [Level] = 1                           )) [IP] = 127.0.0.1 [Useragen                    T] = mozilla/5.0 (Windows NT 6.1; rv:22.0) gecko/20100101 firefox/22.0 [Channeltype] = 1 [from] [spcount] = [Opcount] = [att                                    Achment] = Array ([0] = = Array (                                     [Type] = 1 [desc] =                [url] = http://img.sohu.itc/xxxx)) )        ))

You are the new version of it! Estimated numeric value exceeded max.

You are the new version of it! Estimated numeric value exceeded max.




The new version? What do you say?

I copied the code above saying that the test was normal to me, which is a hint of a data error.
Looks like a real environmental problem.

I copied the code above saying that the test was normal to me, which is a hint of a data error.
Looks like a real environmental problem.

Echo '
   
    
   '; $pingluninfo = <<
      
    
Tested, very normal.
([title] = 123 [url] = http://localhost/?p=9 [Ttime] = 1401327899094 [SourceID] + 9 [paren            TID] = 0 [CategoryID] = [ownerID] = [metadata] = [comments] + = Array (                    [0] = = Array ([Cmtid] = 358 [CTime] = 1401327899094 [Content] = August 1, 2013 18:36:29 O (∩_∩) o~ [Replyid] = 0 [user] = > Array ([userid] = 1 [nickname] =&gt ;                             admin [Usericon] = [Userurl] =                                    [Usermetadata]/= Array ([area] = Beijing                                     [Gender] = 1 [KK] =     [Level] = 1                           )) [IP] = 127.0.0.1 [Useragen                    T] = mozilla/5.0 (Windows NT 6.1; rv:22.0) gecko/20100101 firefox/22.0 [Channeltype] = 1 [from] [spcount] = [Opcount] = [att                                    Achment] = Array ([0] = = Array (                                     [Type] = 1 [desc] =                [url] = http://img.sohu.itc/xxxx)) )        ))

I copied the code above saying that the test was normal to me, which is a hint of a data error.
Looks like a real environmental problem.

     ";p Rint_r ($pingluninfo); echo"
";


Output:
Array ([title] = 123 [url] = http://localhost/?p=9 [Ttime] = 1401327899094 [SourceID] + 9 [            ParentID] + 0 [CategoryID] = [ownerID] + [metadata] = [comments] = = Array (                     [0] = = Array ([Cmtid] = 358 [CTime] = 1401327899094 [Content] = August 1, 2013 18:36:29 O (∩_∩) o~ [Replyid] = 0 [US  ER] = Array ([userid] = 1 [nickname]                             = = admin [Usericon] [userurl] = =                                    [Usermetadata]/= Array ([area] = Beijing                                     [Gender] = 1 [KK] = [Level] = 1                                )) [IP] = 127.0.0.1 [use                    Ragent] = mozilla/5.0 (Windows NT 6.1; rv:22.0) gecko/20100101 firefox/22.0 [Channeltype] = 1                     [From] = [Spcount] [opcount] = =                                [Attachment] = = Array ([0] = = Array                                     ([Type] = 1 [desc] = =                [url] = http://img.sohu.itc/xxxx)) )        ))


Test error
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.