Nandakumar Edamana
Promotional poster with the text 'Vara: Minimalist digital painting'
Share on:
@ R t f

FAQ on libnanjson

  1. What is libnanjson?
  2. What is JSON?
  3. Is libnanjson the only JSON processing library? If not, how it differs from others?
  4. Is libnanjson a fork of any other project?
  5. Does libnanjson have any dependecies?
  6. Is there any command line interface to libnanjson?
  7. Can I use libnanjson in Python?
  8. Which programming languages are supported by libnanjson?
  9. Does libnanjson support unquoted member names (identifiers)?
  10. Does libnanjson support single-quoted strings?
  11. Does libnanjson support comments?
  12. What about Unicode support?
  13. Does libnanjson provide callback functions so that I'll be notified immediately after a new token is identified? Also, can I terminate tokenizing or parsing before the entire data is processed?
  1. What is libnanjson?

    libnanjson is a software library that helps other programs to process JSON data. That means, if you are a developer, you can rely on libnanjson to process JSON in your programs rather than doing it yourself. If you are a regular computer user, probably you don't have to deal with libnanjson directly. The programs you use and the operating system will take care of everything.

  2. What is JSON?

    JSON, JavaScript Object Notation, is a simple yet useful data interchange format. It has become one of the most popular data interchange formats used by websites and webapps, replacing XML in many cases. Clearly human-readable, JSON is stored as plain text. At the same time, JSON data can be directly converted into JavaScript objects (hence the name), or used in other programming languages after parsing.

    I hope JSON will replace XML files in non-Web programs also. For instance, desktop applications can use JSON instead of XML to store configuration files. This will make them more user-friendly. And in such a situation, libnanjson can serve your application.

  3. Is libnanjson the only JSON processing library? If not, how it differs from others?

    Certainly not. json.org already lists around 200 JSON processing libraries, among which 16 are C bindings (as of 17 May 2018).

    I developed libnanjson to meet my requirements, and I think there will be more developers who'd like the way libnanjson perceives and does things.

    For the second question, I can't give you a clear answer since I don't have sufficient experience with other JSON libraries.

  4. Is libnanjson a fork of any other project?

    No, I wrote it from scratch. I've reused some code written for my C compiler (which is yet incomplete), and that was also written by myself entirely.

  5. Does libnanjson have any dependecies?

    Just the standard C library, which means you can use it on any modern operating system with no additional installations.

  6. Is there any command line interface to libnanjson?

    Currently none. If you've developed one, please let me know.

  7. Can I use libnanjson in Python?

    You can use ctypes to call libnanjson functions from Python, until a true Python binding for libnanjson comes. But for most basic applications, you won't be needing libnanjson in Python since it already provides a module named json.

  8. Which programming languages are supported by libnanjson?

    As of now, the official libnanjson API is released in the form of C header files. The same can be used with C++ or any other compatible language.

    You can link your Assembly program with libnanjson, where header files are not needed technically, but can be used to understand the size and order of the parameters.

    You can develop your own libnanjson bindings for other languages. If you do so, please let me know so that I can list it here.

  9. Does libnanjson support unquoted member names (identifiers)?

    Yes, by default. You can turn it off by using nj_flags_set_allow_unquoted_id(false).

  10. Does libnanjson support single-quoted strings?

    Not by default. But you can turn it on by using nj_flags_set_allow_single_quoted_string(true).

  11. Does libnanjson support comments?

    No, unless you embed them as regular JSON members. I've started working on flags to enable the optional support for comments, but it remains unimplemented as of 17 May 2018. Moreover, it is not of high priority since the JSON standard doesn't support comments.

  12. What about Unicode support?

    libnanjson has full support for UTF-8 encoding, UTF-16 escape sequences (\uXXXX) and UTF-16 surrogate pairs. Some examples are given below. Please note that you'll be needing Unicode Emoji fonts to display one of them correctly.

    ALatin Capital Letter A (ASCII/UTF-8)
    \u0041Latin Capital Letter A (ASCII/UTF-8-encoded UTF-16 Escape Sequence)
    😊U+1F60A Smiling Face With Smiling Eyes (ASCII/UTF-8-encoded)
    \uD83D\uDE0AU+1F60A Smiling Face With Smiling Eyes (ASCII/UTF-8-encoded UTF-16 Escape Sequence)

    NOTE: Although libnanjson supports UTF-16 escape sequences included in a string encoded in ASCII/UTF-8, it need not work with strings encoded in UTF-16.

  13. Does libnanjson provide callback functions so that I'll be notified immediately after a new token is identified? Also, can I terminate tokenizing or parsing before the entire data is processed?

    Both of these features--callback and premature termination--will be useful, but remain unimplemented in libnanjson as of now. At present, you can iterate through the tokens after the whole data is tokenized, or iterate through the members after the whole token list is parsed. You can also make use of the search facility, again only after the whole data is parsed.

    This model actually makes coding simple for you, and won't be resource-intensive in most practical cases. However, if you care about memory and time that much, and are dealing with extremely large files, you'll have to look for some other JSON library that supports these features.

    Please note that there is a good chance I add these features soon.