JSON string to the background PHP processing problem solution, JSON string _php tutorial

Source: Internet
Author: User

JSON string to the background PHP processing problem solution, JSON string


In the development of the project due to the introduction of the batch record array, because of the number of fields, it is impossible to use the normal way &a=322&=gsd&v=rwe so to send, so think of the front end of the JSON format past content=[{' a ': 2321 , ' B ': ' GSD ', ' C ': ' Dww '},{' a ': ' 4sd ', ' B ': ' Gsd2 ', ' C ': ' DWW3 '},.....] , so many records background parsing is also very convenient, but when I pass the background received is [{\ ' a\ ': 2321,\ ' b\ ': \ ' gsd\ ', \ ' c\ ': \ ' dww\ '} ...] such format, and I need the standard JSON format string, The use of PHP Json_decode parsed directly into the array, so I am good operation, to the online search a lot of classmates also met with me the same problem, find a half-day best still did not find the answer, and finally the whole out, stripslashes with PHP in this function, Convert the retrieved JSON string to OK,

In fact, this problem is caused by the GET_MAGIC_QUOTES_GPC () function, if the configuration in the php.ini is off should not have this problem, so the use of this function when added judgment

$json for the received JSON string if (GET_MAGIC_QUOTES_GPC () ==1) {  $json = stripslashes ($json);}

Needless to say, two years did not complete the PHP, have forgotten, the recent project needs to go through the handbook

http://www.bkjia.com/PHPjc/1133017.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133017.html techarticle JSON string to the background PHP processing problem resolution, JSON string in the project development due to the introduction of the batch record array, because of the number of fields, it is impossible to use the PU ...

  • 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.