Thursday, February 13, 2014

JSON Graph (JSONG)

Netflix Reactive REST @ InfoQ

To avoid duplication of data and use HTTP more efficiently,
using ID's for data in JSON : JSON Graph (JSONG)
Very interesting!

JSON

{
videoLists: {
“0”: {
  “name”: “Thrillers”,
  “0”: {
    id: 2654,
    name: “Die hard”,
    rating: 4.0
  }, 
// more titles
  length: 74,
},
“1”: {
  “name”: “Action Movies”,
  “0”: {
     id: 2654, // duplication!
     name: “Die hard”,
     rating: 4.0
  }, 
// more titles
  length: 74
}, // more lists…
length: 25
}
} 

JSONG

{
videoLists: {
“0”: {
  “name”: “Thrillers”,
  “0”: [“videos”, 2654],  // effectively a link in a graph!
  // more titles
  length: 74,
},
“1”: {
  “name”: “Action Movies”,
  “0”: [“videos”, 2654], 
  // more titles
length: 74
}, // more lists…
length: 25
},
videos: {
  2654: { // avoid duplication
    name: “Die hard”,
    rating: 4.0 
  }
}
} 
Hierarchical API: JSONG Path [videoLists’][0][0][‘name’]
[“videoLists”,0,0,”name”]
array must be a path
[“videos”, 2654]

1 comment:

Unknown said...

I think that it would be better to use Json pointer instead of an array to set where the information is stored. It would be easier to follow and also easier to implement. But of course it is a really interesting idea.