JSON object max size? JSON object max size? json json

JSON object max size?


This is probably due to your server's configuration. Check php.ini for the setting max_post_size and ensure that it is sufficiently large to post your data. Also check your web server settings - Apache has a LimitRequestBody directive which could be causing your problem. Finally, check your web server and PHP error logs to see if the large post is triggering any errors.


Just a couple of pointers to anyone else who finds this page - I ran into a similar issue with a JSON string failing to be parsed using jQuery.parseJSON().

I'm embarrassed to say my issue (probably unrelated to OP's issue) was actually caused by a stray single quote. Escaping it resolved the issue. I had orginally thought it was string length related, as it only seemed to be happening with an 8,000 character long JSON string, but it was the stray quote terminating the string in the wrong place.

Tim, I don't know if you ever got to the bottom of your original issue, but pasting the string you supplied:

{"events":[{"dates":["2009-10-10","2009-10-11","2009-10-12"],"divisions":[{"level":"Collegiate","name":"Varsity","subdivision":"Division I","rounds":[],"teams":[{"id":"0","country":"USA","state":"CA","name":"California Polytechnic State University","subteam":""},{"id":"1","country":"USA","state":"CA","name":"California State University, Bakersfield","subteam":""},{"id":"2","country":"USA","state":"CA","name":"California State University, Fresno","subteam":""},{"id":"3","country":"USA","state":"CA","name":"California State University, Fullerton","subteam":""},{"id":"4","country":"USA","state":"CA","name":"Stanford University","subteam":""},{"id":"5","country":"USA","state":"CA","name":"University of California, Davis","subteam":""},{"id":"6","country":"USA","state":"CA","name":"San Francisco State University","subteam":""},{"id":"7","country":"USA","state":"CA","name":"Lassen Community College","subteam":""},{"id":"8","country":"USA","state":"CA","name":"Menlo College","subteam":""},{"id":"9","country":"USA","state":"CA","name":"Fresno Pacific University","subteam":""},{"id":"10","country":"USA","state":"CA","name":"Bakersfield","subteam":""},{"id":"11","country":"USA","state":"CA","name":"Buchanan","subteam":""},{"id":"12","country":"USA","state":"CA","name":"Campolindo-Moraga","subteam":""},{"id":"13","country":"USA","state":"CA","name":"Fremont-Sunnyvale","subteam":""},{"id":"14","country":"USA","state":"CA","name":"Ponderosa-Shingle Springs","subteam":""},{"id":"15","country":"USA","state":"CA","name":"West Covina","subteam":""},{"id":"16","country":"USA","state":"CA","name":"Gilroy","subteam":""},{"id":"17","country":"USA","state":"CA","name":"San José State University","subteam":""},{"id":"18","country":"USA","state":"CA","name":"University of California, Los Angeles","subteam":""},{"id":"19","country":"USA","state":"CA","name":"Sierra College","subteam":""},{"id":"20","country":"USA","state":"CA","name":"Selma","subteam":""},{"id":"21","country":"USA","state":"CA","name":"Liberty","subteam":""}],}]}]}

into http://json.parser.online.fr/ gives the following error, if this is of any help to anyone else:

SyntaxError: JSON.parse: expected double-quoted property name


It seems like there is a size issue, when testing my Json string everything works when the string is small ,when I increment the string (php array to be encoded) the output of the Json string gets chopped off.

when doing a string length on the failed string , I get (7796) . So I changed the max post option in the ini file both for the cli and apache to 64M instead of 8M and I am still getting the same problem. I do not think this problem is restricted to the apache LimitRequestBody since the php gives the same output on CLI.

One more thing, when doing a var_dump on the encoded json string, I can see when it gets chopped of and the json tags do not get closed, hence why the Json decoder return a null.

e.g

$strJson = file_get_contents('http://mydomain/page');var_dump($strJson);

You will see where the string is being chopped off and a zero is concatenated to end of the output.