Some insight about Json parser.

About Monkey 2 Forums Monkey 2 Development Some insight about Json parser.

This topic contains 1 reply, has 2 voices, and was last updated by  Mark Sibly 2 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2853

    cocon
    Participant

    I try to parse a JSON file like in this format above. With some debugging help, I see that the json parser can’t return a JsonObject , although the file is found and the content is loaded.

    After trying lots of hours with this silly mistake I found that the very last comma (at the “Four” line) is not needed.

    However here is the catch, my experience with web development says that trailing commas are allowed in Javascript but they are not allowed in the specification. http://www.json.org/

    And the funny thing is that some online linters fall towards browser compatibility, others towards the standard, so you can’t decide for sure if your json is browser-valid or standard-valid.

    https://1drv.ms/u/s!AquVr9J7xRcsgWstdolGgysJ-p4e

    #2890

    Mark Sibly
    Keymaster

    The Json parser definitely needs better error feedback! I’ve been using this to validate my json lately:

    http://www.jsoneditoronline.org/

    I think the default behaviour of the parser should definitely be ‘standard-valid’ as it ensures your json will work anywhere. but I’m open to the idea of adding some JsonParserFlags that allow things like extra trailing commas, comments in json etc.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.