Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am new in json i have get the following json string from my app now i want to parse it in php but this syntax (logjson=) in json file is confused me that now how i can the display it?
logjson='[{"Ct":"aaa","Er":"1","Ve":"1","Ie":"12","Date":"15-7-22","We":"15-7-21"},{"Ct":"a2a","Er":"21","Ve":"21","Ie":"212","Date":"25-7-22","We":"95-7-21"}]'


What I have tried:

if(isset($_POST['logjson']))
 {$someArray = json_decode(file_get_contents('php://input'), true);
file_put_contents('test.txt',$someArray[logjson]["Count"]);

}

it show me only empty text file .
Posted
Updated 27-Mar-20 2:36am
v2

1 solution

You're trying to decode the entire request body, rather than the specific JSON field. Try:
PHP
if (isset($_POST['logjson']))
{
    $someArray = json_decode($_POST['logjson']);
    ...
}
 
Share this answer
 

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