I have a client that uses JSON to represent objects. For instance:
var person = { fname: "John", lname: "Doe", nicknames: ["jake", "kevin"] }
To edit these entries, we would like to include a GUID for each object. The GUID embed method has not yet been set. I am now thinking of doing something like this:
var person = { _guids: { fname: "XXX", lname: "XXX", _nicknames: "XXX", nicknames: ["jake-guid", "kevin-guid"], } fname: "John", lname: "Doe", nicknames: ["jake", "kevin"] }
If each element should be its own object, it would become extremely messy and would prohibit pure exchanges in cases where GUIDs are not needed. However, this approach also leads to the question of how to deal with something like this:
var person = { _guids: { fname: "XXX", lname: "XXX", sacks_of_marbles: ["container-guid", "first-sacks-guid", ["XXX", "XXX"], "second-sacks-guid", ["XXX", "XXX"]] } fname: "John", lname: "Doe", sacks_of_marbles: [["red", "blue-with-swirls"], ["green", "pink"]] }
Any recommendations on how to maintain cleanliness, lack of verbosity, and the ability to include a GUID?