Created
February 21, 2017 19:44
-
-
Save georgeportillo/4cce1b93a5f414ea8db4f5a253bd0922 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
var linked_tree = [{ | |
id: '1-abc' | |
value: '...' | |
}, { | |
id: '2-abc', | |
parent: '1-abc', | |
value: '...' | |
}, { | |
id: '2-def', | |
parent: '1-abc', | |
value: '...' | |
}, { | |
id: '3-abc', | |
parent: '2-abc', | |
value: '...' | |
}]; | |
// Convert to | |
var linked_tree = [{ | |
id: '1-abc' | |
value: '...', | |
nodes: [{ | |
id: '2-abc', | |
parent: '1-abc', | |
value: '...' | |
}, { | |
id: '2-def', | |
parent: '1-abc', | |
value: '...', | |
nodes: [{ | |
id: '3-abc', | |
parent: '2-abc', | |
value: '...' | |
}] | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do?