JSON object max size?

前端 未结 4 1922
名媛妹妹
名媛妹妹 2020-12-15 21:35

Using jquery, I\'m able to send json objects from client to server using ajax like this:

var strJSON = \'{\"event\":[{
    \"dates\":[
        \"2009-10-14\"         


        
4条回答
  •  不思量自难忘°
    2020-12-15 22:08

    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

提交回复
热议问题