My goal is to be able to keep track of my position/depth in a JSON tree by adding elements to an Array and then access nested nodes in the JSON utilizing this Array. By now say the Array foo it has one element:
foo = ["customers"] so that element would act as a reference for a JSON children, say:
jsonTree["customers"] where jsonTree is something like:
{ "customers":{ "name": "J. Goldsmith", "orders": [{ "order": "1", "order": "2" }] } } Then foo eventually varies its size and become
foo = ["customers","orders"] So the JSON reference would become
jsonTree["customers"]["orders"] Now say that customers.orders can become customers.orders.order.date.etc.etc... Is there any way to build the jsonTree reference programmatically with N dimensions based on the N elements of foo Array?
Some examples:
I have ["John","Williams"] -> i want to build composer["John"]["Williams"] ["Erich","Wolfgang","Korngold"] -> i want to build composer["Erich"]["Wolfgang"]["Korngold"]
var multi = [[1,2,3],[4,5,6],[7,8,9]];. :-) I guess there's nothing stopping you from doingvar multi = ['a',[1,2,3],'b',[4,5,6],'c',[7,8,9,10]];:-P