Skip to content

Instantly share code, notes, and snippets.

@Rio517
Last active May 27, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rio517/0a70d0027ceb65af510c3f55eb3cd159 to your computer and use it in GitHub Desktop.
Save Rio517/0a70d0027ceb65af510c3f55eb3cd159 to your computer and use it in GitHub Desktop.
Example Ember JSON Format for sideloading
{
"classrooms" : [
{
"classroom_name" : "Class 1",
"id" : 1,
"teacher_id" : 3,
"grade" : 5,
"assignments" : [
],
"student_ids" : [ 5 ]
},
{
"classroom_name" : "Class 3",
"id" : 2,
"teacher_id" : 3,
"grade" : 4,
"assignments" : [
{
"id" : 5,
"assignment_overview" : "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\r\n\r\nNam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.",
"assignment_title" : "Fractions",
"story" : null
}
],
"student_ids" : [ 5, 3, 6]
}
],
"students" : [
{
"id" : 5,
"first_name" : "Henry",
"last_name" : "Ford",
"district_id_number" : "MD454"
},
{
"id" : 3,
"first_name" : "Jake",
"last_name" : "Strong",
"district_id_number" : "WH6879"
},
{
"id" : 6,
"first_name" : "Bryan",
"last_name" : "Dobson",
"district_id_number" : "B453"
}
]
}
{
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"links": {
"self": "http://example.com/articles/1"
},
"relationships": {
"author": {
"links": {
"self": "http://example.com/articles/1/relationships/author",
"related": "http://example.com/articles/1/author"
},
"data": { "type": "people", "id": "9" }
},
"comments": {
"links": {
"self": "http://example.com/articles/1/relationships/comments",
"related": "http://example.com/articles/1/comments"
},
"data": [
{ "type": "comments", "id": "5" },
{ "type": "comments", "id": "12" }
]
}
}
}]
}
{
"posts": [
{ "id": 1,
"title": "Side-load Like a Pro With Ember-RESTless",
"body": "...",
"author": "Matt Rozema"
}, {
"id": 2,
"title": "Another really good blog post",
"body": "...",
"author": "John Doe"
}
],
"comments": [
{ "id": 1, "author": "John Doe", "comment": "Amazing post!", "post_id": 1 },
{ "id": 2, "author": "Jane Doe", "comment": "Life Changing!", "post_id": 1 },
{ "id": 3, "author": "Mrs. Doe", "comment": "You rock!", "post_id": 2 }
]
}
{
"data": [
{
"id": "1",
"type": "pictures",
"links": {
"self": "http://localhost:3000/api/v1/pictures/1"
},
"attributes": {
"name": "box of chocolates"
},
"relationships": {
"imageable": {
"links": {
"self": "http://localhost:3000/api/v1/pictures/1/relationships/imageable",
"related": "http://localhost:3000/api/v1/pictures/1/imageable"
},
"data": {
"type": "products",
"id": "3"
}
}
}
},
{
"id": "2",
"type": "pictures",
"links": {
"self": "http://localhost:3000/api/v1/pictures/2"
},
"attributes": {
"name": "10 foot candy cane"
},
"relationships": {
"imageable": {
"links": {
"self": "http://localhost:3000/api/v1/pictures/2/relationships/imageable",
"related": "http://localhost:3000/api/v1/pictures/2/imageable"
},
"data": {
"type": "products",
"id": "2"
}
}
}
},
{
"id": "3",
"type": "pictures",
"links": {
"self": "http://localhost:3000/api/v1/pictures/3"
},
"attributes": {
"name": "Hot apple fritter"
},
"relationships": {
"imageable": {
"links": {
"self": "http://localhost:3000/api/v1/pictures/3/relationships/imageable",
"related": "http://localhost:3000/api/v1/pictures/3/imageable"
},
"data": {
"type": "products",
"id": "1"
}
}
}
},
{
"id": "4",
"type": "pictures",
"links": {
"self": "http://localhost:3000/api/v1/pictures/4"
},
"attributes": {
"name": "Boston Creme"
},
"relationships": {
"imageable": {
"links": {
"self": "http://localhost:3000/api/v1/pictures/4/relationships/imageable",
"related": "http://localhost:3000/api/v1/pictures/4/imageable"
},
"data": {
"type": "products",
"id": "1"
}
}
}
},
{
"id": "5",
"type": "pictures",
"links": {
"self": "http://localhost:3000/api/v1/pictures/5"
},
"attributes": {
"name": "Bill at EmberConf"
},
"relationships": {
"imageable": {
"links": {
"self": "http://localhost:3000/api/v1/pictures/5/relationships/imageable",
"related": "http://localhost:3000/api/v1/pictures/5/imageable"
},
"data": {
"type": "employees",
"id": "1"
}
}
}
}
],
"included": [
{
"id": "3",
"type": "products",
"links": {
"self": "http://localhost:3000/api/v1/products/3"
},
"attributes": {
"name": "Chocolates"
},
"relationships": {
"pictures": {
"links": {
"self": "http://localhost:3000/api/v1/products/3/relationships/pictures",
"related": "http://localhost:3000/api/v1/products/3/pictures"
}
}
}
},
{
"id": "2",
"type": "products",
"links": {
"self": "http://localhost:3000/api/v1/products/2"
},
"attributes": {
"name": "Candy Canes"
},
"relationships": {
"pictures": {
"links": {
"self": "http://localhost:3000/api/v1/products/2/relationships/pictures",
"related": "http://localhost:3000/api/v1/products/2/pictures"
}
}
}
},
{
"id": "1",
"type": "products",
"links": {
"self": "http://localhost:3000/api/v1/products/1"
},
"attributes": {
"name": "Donuts"
},
"relationships": {
"pictures": {
"links": {
"self": "http://localhost:3000/api/v1/products/1/relationships/pictures",
"related": "http://localhost:3000/api/v1/products/1/pictures"
}
}
}
},
{
"id": "1",
"type": "employees",
"links": {
"self": "http://localhost:3000/api/v1/employees/1"
},
"attributes": {
"name": "Bill Heaton"
},
"relationships": {
"pictures": {
"links": {
"self": "http://localhost:3000/api/v1/employees/1/relationships/pictures",
"related": "http://localhost:3000/api/v1/employees/1/pictures"
}
}
}
}
],
"meta": {
"page": {
"total": 7,
"sort": [
{
"field": "id",
"direction": "asc"
}
],
"offset": 0,
"limit": 5
}
},
"links": {
"first": "http://localhost:3000/api/v1/pictures?include=imageable&page%5Blimit%5D=5&page%5Boffset%5D=0",
"next": "http://localhost:3000/api/v1/pictures?include=imageable&page%5Blimit%5D=5&page%5Boffset%5D=5",
"last": "http://localhost:3000/api/v1/pictures?include=imageable&page%5Blimit%5D=5&page%5Boffset%5D=2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment