Skip to content
Examples of JSON parsing / generation and http requests in various languages
C
Failed to load latest commit information.
c Cleanup C example, fixing some potential bugs Jan 9, 2013
README.md README.md emphasis addition Jan 9, 2013

README.md

json-examples

Examples of JSON parsing / generation and http requests in various languages

Solutions Explored

Demo code has been written in the following languages:

  1. Javascript
    • jQuery (in Browser, all the hard stuff is handled)
    • NodeJS (Best HTTP and JSON support; server-side)
  2. Ruby
  3. Python
  4. luvit (lua)
  5. C#
  6. Java
  7. curl (exec from any language)
  8. bash
  9. 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:

  1. 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:

  1. GoLang (or Go for short)

IMPORTANT

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

Examples

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)

SDK

One day we'll have an SDK...

Something went wrong with that request. Please try again.