Skip to content

Instantly share code, notes, and snippets.

@walesmd
Created August 14, 2013 01:31
Show Gist options
  • Save walesmd/6227290 to your computer and use it in GitHub Desktop.
Save walesmd/6227290 to your computer and use it in GitHub Desktop.
Correct JSON-API Example Our response consists of a single array with the same name as our table. Notice this is using the ID format in that foreign keys return the primary key to the joined table. A URL format is available and preferred, so that the client can be completely unaware / agnostic in regards to the backend. In ID format, we must har…
{
"datacenters": [{
"id": "1",
"name": "Albany Center",
"lat": "42.64957",
"lng": "-73.77459",
"city": "Albany",
"state": "NY",
"zip": "12208",
"createdAt": "2013-06-24",
"updatedAt": "2013-06-30",
"ownershiptype_id": "4"
}, {
"id": "2",
"name": "Albany Backup",
"lat": "42.64957",
"lng": "-73.77459",
"city": "Albany",
"state": "NY",
"zip": "12208",
"createdAt": "2013-06-24",
"updatedAt": "2013-06-30",
"ownershiptype_id": "4"
}
]
}
{
"datacenter": {
"id": "1",
"name": "Albany Center",
"lat": "42.64957",
"lng": "-73.77459",
"city": "Albany",
"state": "NY",
"zip": "12208",
"createdAt": "2013-06-24",
"updatedAt": "2013-06-30",
"ownershiptype_id": "4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment