JSON is much shorter than the equivalent PHP. Consider the following $arr object that we have created in PHP that has five properties each with a different value. The json_encode() call will result in the JSON equivalent being output to the page:
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
Running this code results in the following being written to the page.
$json = json_encode($arr);
This results in the following being written to the page (the true in the second parameter converts the object being returned into an associative array which is what we started with and so gives the same end result as calling var_dump on the original associative array):
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
This article written by Stephen Chapman, Felgall Pty Ltd.