Okay, so this grabbed my attention and I'm interested, so I did a quick test.
First, I generated a 783K json file using the following code (granted it doesn't have nested arrays, but I planned on building that in later):
$keys = array();
for ($i = 0; $i < 100; $i++)
$keys = randomString(6);
$objs = array();
for ($i = 0; $i < 400; $i++)
$obj = array();
foreach ($keys as $key)
$obj[$key] = randomString(8);
$objs = $obj;
$str = '';
$validChars = VALID_CHARS;
$validCharsLength = strlen($validChars);
for ($i = 0; $i < $length; $i++)
$str .= $validChars[mt_rand(1, $validCharsLength) - 1];
Then I created a script that reads the file and performs json_decode:
$content = file_get_contents('data/objects.json');
$objs = json_decode($content);
Both run in a split second on my development machine (granted I've got a quad-core 8 GB RAM machine, but I really don't see this being your hold up).
Next I profiled the code using xDebug, the time to run build.php was 1,166 ms, 63% of the time to run was in randomString (which you wouldn't have, but you would have something that generates your objects).
read.php ran in 42 ms. 97% of the time was spent in json_decode (DUH! there were only two lines, what did you expect?).
So now I obviously need to go bigger, and see if I can start seeing seconds instead of ms.
2M file, I changed 400 to 1000 in the build.php
Profiler shows 3,135 ms for build.php, with 57% in randomString, and read.php shows 105 ms with 98% being in json_decode.
So from these numbers I have concluded thus far that as the file size grew (ie the number of objects grew) the time to build the json encode file did not increase, it remained pretty static (granted I didn't make a big leap, but I did go from 700K to 2M in file size). The read.php reacted the same as the build.php, so reading the larger file didn't adversely affect performance either.
I've attached my profiles here and the code for others to observe as well, but I strongly think you need to setup xDebug and figure out where your bottlenecks are at, as I don't believe it is json_encode or json_decode directly.