JSON string upload to background PHP solution for problem solving _php tips

Source: Internet
Author: User

In the development of the project due to the introduction of the batch record array, due to many fields, so it is impossible to &a=322&=gsd&v=rwe in the ordinary way to transmit, so thought of the front-handed JSON format in the 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 did this, backstage received the [{\ ' a\ ': 2321,\ ' b\ ': \ ' gsd\ ', \ ' c\ ': \ ' dww\ '} ...] such a format, and I need the standard JSON format string, The use of PHP Json_decode parse directly into the array, so I would be good operation, online search a lot of students also encountered and I have the same problem, looking for a half-day best still did not find the answer, finally or their own whole out, stripslashes with PHP in this function, It's OK to convert the captured JSON string.

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

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

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

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.