The JSON string is uploaded to the backend PHP to solve the problem. The json string

Source: Internet
Author: User

The JSON string is uploaded to the backend PHP to solve the problem. The json string

During project development, due to the introduction of batch record arrays, due to the large number of fields, it is impossible to use the common method & a = 322 & = gsd & v = rwe to transfer data, so I thought of the frontend's passing the JSON format content = [{'A': 2321, 'B': 'gsd', 'C': 'dww'}, {'A ': '4sd', 'B': 'gsd2', 'C': 'dww3'},...], in this case, it is very convenient to Parse Multiple records in the background, but what I received in the background when I passed this message is [{\ 'a \ ': 2321, \' B \': \ 'gsd \ ', \ 'C \': \ 'dww \ '}...] in this format, the JSON string that I need is parsed using PHP's json_decode and then directly converted to an array, so that I can operate on it, after searching online, many people also encountered the same problem as me. After searching for a long time, I had better not find the answer, and finally I made it myself. stripslashes used this function in PHP, convert the obtained JSON string to OK,

In fact, this problem is caused by the get_magic_quotes_gpc () function. If the configuration in php. ini is off, it should be okay. Therefore, when using this function, add a judgment.

// $ Json is the received JSON string if (get_magic_quotes_gpc () = 1) {$ json = stripslashes ($ json );}

I forgot to say a few things about PHP for two years. I have to go through the manual for the latest project.

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.