Skip to content

Instantly share code, notes, and snippets.

@mrnugget
Created July 16, 2012 10:42
Show Gist options
  • Select an option

  • Save mrnugget/3122081 to your computer and use it in GitHub Desktop.

Select an option

Save mrnugget/3122081 to your computer and use it in GitHub Desktop.
JSON API - What's preferable?

What do you prefer as output of a JSON API?

Hash

{
  "foo": "bar",
  "the_list": {
    "list_item_one": {
      "foo": "bar",
      "foo": "bar"
    },
    "list_item_two": {
      "bar": "foo",
      "bar": "foo"
    },
  }
}

Array

{
  "foo": "bar",
  "the_list": [
    {
      "name": "list_item_one",
      "foo": "bar",
      "foo": "bar"
    },
    {
      "name": list_item_two",
      "bar": "foo",
      "bar": "foo"
    },
  ]
}

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