Created
December 7, 2016 02:29
-
-
Save kaw2k/138b3b00363bce6cfc4db256b86374a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const treeArray = [ | |
{ path: 'name', value: 'name' }, | |
{ path: 'meta.age', value: 'age' }, | |
{ path: 'meta.eyes', value: 'eyes' }, | |
{ path: 'friends.[0]', value: 'friends 0' }, | |
{ path: 'friends.[1]', value: 'friends 1' }, | |
{ path: 'friends.[2]', value: 'friends 2' }, | |
{ path: 'friends.[3].name', value: 'friends 3 name' }, | |
] | |
const makeJson = (arrayOfNodes) => { /* ... */ } | |
console.log(makeJson(treeArray)) | |
/* | |
{ | |
name: 'name', | |
meta: { | |
age: 'age', | |
eyes: 'eyes' | |
}, | |
friends: [ | |
'friends 0', | |
'friends 1', | |
'friends 2', | |
{ | |
name: 'friends 3 name' | |
} | |
] | |
} | |
/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this cheating?