mysql - relationship in json data vs actual relationship in db -


i thought know later on stuck , became confused. want ask possible 'think relationship' in json or can done when u designing backend?

json doesn't support object references, javascript objects do. can store functions, first class citizens.

http://en.wikipedia.org/wiki/json#object_references

var anna = {name: "anna"}; var bob = {name: "bob", knows: [anna]}; var charlie = {name: "charlie", knows: [anna, bob]} anna.knows = [charlie, bob];  // 'bob' alert(charlie.knows[0].knows[1].name)  // -------------------------------------------------  var call = function(destination) {     alert(this.name + " calls " + destination.name); } bob.call = call;  // 'bob calls charlie' bob.call(charlie); 

but beware of infinite loops!
(bob knows anna, anna knows bob, bob knows anna, ...)

in json, relationships can represented value (which ideally unique id of record). duplicate name, , need entry name find refers to.

var ob_from_json = json.parse('     {         "bob": {"name": "bob", "knows": ["anna"]},         "anna: {"name": "anna", "knows": ["bob"]}     } ');  // 'anna' ob_from_json[ob_from_json["bob"].knows[0]].name 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -