JSON issue
Posted: Thu Nov 03, 2011 2:53 am
I'm trying to use json_decode() on a value i receive from an ajax call. The information i receive from the call looks correct ( "info":"58" ) but when i use json_decode() to display it to the browser, it displays as {\"info\":\"58\"}. From phpinfo i determined that json support is enabled, the version is 1.2.1 and the php version is 5.2.5. What's the correct method to use json_decode()?
A final point, if i call json_last_error() i get an undefined function fatal error
Edit
When i stripped the slahses from $_GET['value'] is seems to solve the problem.
Code: Select all
<?php
// if i use the following code i don't get any value printed to the browser
// using the web console in FireFox, the value of $_GET['value'] is
// %22info%22:%22abc%22
$decoded = json_decode($_GET['value']);
print_r($decoded);
?>Edit
When i stripped the slahses from $_GET['value'] is seems to solve the problem.