Re: Euphoria JSON parser

new topic     » goto parent     » topic index » view thread      » older message » newer message
katsmeow said...

What does it do?

Kat

It's a JSON parser. It parses JSON. It also allows you to create JSON objects in memory and output them as JSON text.

With this, you can make use of REST APIs that send and receive JSON data by combining this with http_get() and http_post() calls. Or you could just store some data in a portable human-readable format. Or support importing and exporting data that is compatible with other applications and services.

There have been several unsuccessfuly attempts at adding JSON to Euphoria. I've also run into my own roadblocks trying to get a good JSON parser written in Euphoria. Sometimes it's better to avoid reinventing the wheel and just seek out something that Just Works.

There is also cjson in The Archive, which was added by "ras" in May 2012. That library probably works well but it has a few short-comings:

  • It requires an external library. If the libraries provided are not compatible with the user's system, they will have to be recompiled accordingly (not a trivial task). I have compiled JSMN into the backend of Euphoria.
  • It has a lot of functions to manipulate JSON objects in memory. I have implemented JSMN such that all of the JSON object manipulation is as "close to the bone" as possible in native Euphoria.
  • It has not been updated since 2012 and most likely will not be. With JSMN built into the backend, we will pull updates from upstream when updating Euphoria.

I original started along the same vein as cjson: I compiled JSMN into a shared library and wrapped its two functions, then wrote all of the additional code to format Euphoria objects from the tokens it provides. However, given how small the library is, it was only a few hours work to get the code compiled into the backend so that there are no external dependancies.

This, I believe, is key to adding a lot of good features to Euphoria: zero external dependancies.

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu