How to decode json into array output

Source: Internet
Author: User
How to decode json into array output? A: 2: {I: 0; s: 21: & quot; www & quot; I: 1; s: 16: & quot; eee & quot ;;}, check out json_decodehttp: // php.net/manual/en/function.json-decode.php. do you know how to decode the jsonjson format into an array output?
A: 2: {I: 0; s: 21: "www"; I: 1; s: 16: "eee ";}

------ Solution --------------------
View json_decode

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


------ Solution --------------------
Are you sure this is a correct Json format data?
------ Solution --------------------
Where does the data in the database come from? I don't think it should be Json...

Discussion

Reference:

Are you sure this is a correct Json format data?

Same question
The database is like this!
Json_decode is a value when an array is used.

------ Solution --------------------
Like serialize,
But it's a little strange.
------ Solution --------------------
I have tested it and cannot restore it normally.

Discussion

Like serialize,
But it's a little strange.

------ Solution --------------------
This is not json
------ Solution --------------------
Cms uchome seems to have stored data like this.
------ Solution --------------------
First in this http://jsonlint.com/verify the json format is correct, json converted into an array using json_decode
------ Solution --------------------
This array ('WWW ', 'eee') is read, but the length of the array element is incorrect.
------ Solution --------------------
The format is not json. it is the result of serialize serialization, but the data is obviously faulty.

A: 2: {I: 0; s: 21: "www"; I: 1; s: 16: "eee ";};

Indicates that an array contains two elements. The first element is the string www with a length of 21 (obviously incorrect, the length should be 3 ), the second element is the string eee with a length of 16 (or not)

$ Str = 'A: 2: {I: 0; s: 3: "www"; I: 1; s: 3: "eee ";}';
Var_dump (unserialize ($ str ));
// This should be correct.
------ 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.