How JSON decodes an array of outputs

Source: Internet
Author: User
How does JSON decode an array of outputs?
a:2:{i:0;s:21: "www"; i:1;s:16: "Eee";}

------Solution--------------------
See Json_decode

http://php.net/manual/en/function.json-decode.php


------Solution--------------------
Are you sure this is the correct JSON format data?
------Solution--------------------
Where did the data in the database come from? I don't think he should be json ...

discuss

Reference:

Are you sure this is the correct JSON format data?

Same question
The database is like this!
Json_decode use an array for a value.

------Solution--------------------
Like the Serialize,
But it's a little weird.
------Solution--------------------
I've tested it, I can't restore it properly.

discuss

Like the Serialize,
But it's a little weird.

------Solution--------------------
This is not JSON.
------Solution--------------------
CMS Uchome seems to have stored data like this.
------Solution--------------------
First in this http://jsonlint.com/verify that the JSON format is correct, JSON conversion to the array of words with Json_decode
------Solution--------------------
Read out is this array (' www ', ' eee '); But the length of the array element is not correct
------Solution--------------------
Look, this format is not JSON, it's the result of serialize serialization, but the data is obviously problematic.

a:2:{i:0;s:21: "www"; i:1;s:16: "Eee";};

It means: An array contains two elements, the first element is a string with a length of 21 www (obviously not, the length should be 3), the second element is a string with a length of 16 eee (also not)

$str = ' a:2:{i:0;s:3: "www"; i:1;s:3: "Eee";} ';
Var_dump (Unserialize ($STR));
That should be right.
------Solution--------------------
Array (2) {[0]=> string (3) "www" [1]=> string (3) "Eee"}
  • 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.