Examples of JSON parsing / generation and http requests in various languages
Demo code has been written in the following languages:
- Javascript * jQuery (in Browser, all the hard stuff is handled) * NodeJS (Best HTTP and JSON support; server-side)
- Ruby
- Python
- luvit (lua)
- C#
- Java
- curl (exec from any language)
- bash
- C
However, most of the code we provide is not very robust, so it is in the "untested" branch of this repository. It is provided so the astute programmer can see the basics of normal JSON and HTTP interactions in the language, rather than as a complete, solid application off of which others may build.
Code that is tested and suitable as a starting point is in the master branch. Languages that fall into this category are:
- C
Your mileage may vary. Understand the code you are using before actually using it.
ProTip: Use an Application Language (NodeJS, Python, Ruby) to do all of your HTTP / JSON work coupled with some sort of message passing (such as packing a struct) if you need to use a Systems Language (C, Java, C#).
In the future we hope to also have example code in these languages:
The parser you choose MUST be configureable meet the following criteria:
- IGNORE unexpected and unused fields (new fields will be added in future versions)
- ACCEPT
null
as a non-value for any field type
Additionally:
- when a number is encountered where a string was expected, the number should be treated as a string
- if an expected field does not exist, it should be treated the same as if the value were
null
The eventual goal is to have examples for all of the following in each language:
- HTTP GET request
- HTTP POST request
- JSON parsing (decoding / deserializing)
- Iterating over objects and arrays
- JSON stringifying (encoding / serializing)
One day we'll have an SDK...