What I want to do is the following:
If you are getting the JSON string from the form using $_REQUEST
, $_GET
, or $_POST
the you will need to use the function html_entity_decode()
. I didn't realize this until I did a var_dump
of what was in the request vs. what I copied into and echo
statement and noticed the request string was much larger.
Correct Way:
$jsonText = $_REQUEST['myJSON'];
$decodedText = html_entity_decode($jsonText);
$myArray = json_decode($decodedText, true);
With Errors:
$jsonText = $_REQUEST['myJSON'];
$myArray = json_decode($jsonText, true);
echo json_last_error(); //Returns 4 - Syntax error;