Json data received by url in api-php, json_decode is empty

Source: Internet
Author: User
# The result of json data decode in the php background is empty # I use a mobile phone to transmit data to the php background, and the result of json_decode is empty. The mobile phone transmission method is POSTGET, encoding format is UTF-8. Json data is (including single quotation marks in the code, which are transmitted using strings. json data must be double quotation marks): & quot; & #39 ;{& quot; agent & quot ;: & quot; 30 & quot;, & quot; job & quot;: & quot; 1133 & quot;, & quot; students & quot;: [{& quot; working_hours_un phpapijson: communication between the mobile phone server and the client

# Php background json data decode is empty #
I use my mobile phone to transmit data to the php background. the result of json_decode is blank.
The mobile phone transmission method is POST/GET, the encoding format is UTF-8.
Json data is (including single quotation marks in the code, which are transmitted using strings. json data must be double quotation marks ):

   '{"agent":"30","job":"1133","students":[{"working_hours_unit":"null","working_hours":"6","student_id":"191","commission_unit":"null","wage":"58","commission":"348","wage_unit":"null"}]}'

The php code obtains the preceding json data and can use echo to output the data. Php code:

 $str=$_GET('my_str'); echo $str;

Output the test result and then decode the received json data. Code:

 $form = json_decode($Noel,true); var_dump($form);

Unexpectedly, the output is ** null **. then, I use _ echo json_last_error (); _ to output a json conversion error with the result of 4 = json syntax error.
Complete Code and:

     $str=$_GET('my_str');  echo $str;$form = json_decode($str,true); var_dump($form); echo json_last_error();


However, when I separate the received json into the PHP code, the decode can be correctly parsed. (In my heart, the crash _ crash)
Code :'

     $orm='{"agent":"30","job":"1133","students":[{"working_hours_unit":"null","working_hours":"6","student_id":"191","commission_unit":"null","wage":"58","commission":"348","wage_unit":"null"}]}';  $arr=json_decode($form,true);  var_dump($arr);

:

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.