Loading ...
Sorry, an error occurred while loading the content.

Re: Introducing NXJSON parser (written in C)

Expand Messages
  • wjosdejong
    The cases where I wish I could insert comments in a JSON file are normally cases where the file contains configuration for some application. I think JSON is
    Message 1 of 5 , May 22, 2013
    • 0 Attachment
      The cases where I wish I could insert comments in a JSON file are normally cases where the file contains configuration for some application. I think JSON is excellent as a data interchange format, but much less perfect as configuration format. For configuration files I think formats like yaml and ini are better suitable.

      Jos

      --- In json@yahoogroups.com, Tatu Saloranta <tsaloranta@...> wrote:
      >
      > I think the way most parsers deal with this is to make comment acceptance
      > optional: such that by default it is disabled (produces parsing error), but
      > can be enabled if user explicitly chooses to.
      > This is one of few tough choices with JSON: although standards should be
      > followed, many (including myself) feel omission of comments is a major
      > design flaw in JSON.
      >
      > -+ Tatu +-
      >
      >
      >
      > On Tue, May 14, 2013 at 12:01 AM, wjosdejong <wjosdejong@...> wrote:
      >
      > > Though very practical and desired by many, comments are not supported by
      > > JSON. To prevent compatibility issues in the future, it may be better to be
      > > consistent with the specs...
      > >
      > >
      > > --- In json@yahoogroups.com, "yarosla" <yarosla@> wrote:
      > > >
      > > > NXJSON is full-featured yet very small (~400 lines of code) JSON parser,
      > > which has easy to use API.
      > > >
      > > >
      > > > Features
      > > >
      > > > Parses JSON from null-terminated string
      > > > Easy to use tree traversal API
      > > > Allows // line and /* block */ comments (except before colon ':')
      > > > Operates on single-byte or multi-byte characters (like UTF-8), not wide
      > > characters
      > > > Unescapes string values (including Unicode codepoints & surrogates)
      > > > Can use custom Unicode encoder, UTF-8 encoder built in
      > > > Can use custom memory allocator
      > > > Can use custom macro to print errors
      > > > Test suite included
      > > >
      > > >
      > > > Limitations
      > > >
      > > > Non-validating parser; might accept invalid JSON (eg., extra or missing
      > > commas, comments, octal or hex numeric values, etc.)
      > > >
      > > >
      > > > Example usage
      > > >
      > > > const nx_json* json=nx_json_parse_utf8(code);
      > > > printf("hello=%s\n", nx_json_get(json, "hello")->text_value);
      > > > const nx_json* arr=nx_json_get(json, "my-array");
      > > > int i;
      > > > for (i=0; i<arr->length; i++) {
      > > > const nx_json* item=nx_json_item(arr, i);
      > > > printf("arr[%d]=(%d) %ld\n", i, (int)item->type, item->int_value);
      > > > }
      > > > nx_json_free(json);
      > > >
      > > >
      > > > Project homepage: https://bitbucket.org/yarosla/nxjson
      > > >
      > >
      > >
      > >
      > >
      > > ------------------------------------
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      > >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.