Click here to Skip to main content
15,898,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when I cal the JSON through POST json string  come but decode function not work but when I tried the same JSON without POST it worked why? and how it can be worked with post[$json]?

What I have tried:

<pre>here is the code

      $json=$_POST['logjson'];
      $content = json_decode($json, true);
      file_put_contents('testcontent.txt',$json);//here i get the json string which is'[{"Count":"aaa","Er":"1","Ve":"1","Ie":"12","Dae":"15-7-22","Woe":"15-7-21"}]'
      $e = $content['Count'];
      file_put_contents('test.txt',$e);//here i get null
but when i give the string direct to json like
 $json='[{"Count":"aaa","Er":"1","Ve":"1","Ie":"12","Dae":"15-7-22","Woe":"15-7-21"}]';
now  all code is worked. 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900