Skip to content

Instantly share code, notes, and snippets.

@aharpole
Created May 5, 2015 00:05
Show Gist options
  • Save aharpole/e949f3fadc454796b936 to your computer and use it in GitHub Desktop.
Save aharpole/e949f3fadc454796b936 to your computer and use it in GitHub Desktop.
JSON stuff

Here’s some required reading for all developers using JSON:

JSON’s official spec (in just seven pages!): http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf

If you are planning to make a Hypermedia API: http://json-ld.org/

A few tidbits about how Fullscreen has used JSON:

API responses do not include the root element.

For instance, GET /api/people/12

would return

{
    "name": "Jim Halpert",
    "employer": "Dunder Mifflin"
}

as opposed to

{
  "person": {
    "name": "Jim Halpert",
    "employer": "Dunder Mifflin"
  }
}

Due to legacy Rails constraints, most of our floating-point data in JSON is in string format.

Although your keys can be symbolized in JavaScript, JSON data must put keys in quotation marks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment