Json problem obtained from the database-php Tutorial

Source: Internet
Author: User
I saved a piece of JOSN code in a field in the data inventory, but the double quotation marks were escaped after the code was saved.
Like This

[{& Quot; id & quot;: & quot; 9 & quot;, & quot; model & quot;: & quot; A2 & quot;, & quot; quantity & quot;: 1}]


It is also displayed in html without quotation marks.
How can I convert it into json code.


Reply to discussion (solution)

[{"Id": "9", "model": "A2", "quantity": 1 },{ "id": "8", "model ": "A1", "quantity": 1}]


It should have been like this.

$ S = '[{& quot; id & quot;: & quot; 9 & quot;, & quot; model & quot;: & quot; A2 & quot ;, & quot; quantity & quot;: 1}] '; echo html_entity_decode ($ s ));
[{"Id": "9", "model": "A2", "quantity": 1}]

When you import data to the database, you perform htmlentities encoding conversion. Naturally, you cannot directly use it.

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.