Skip to content

Instantly share code, notes, and snippets.

@JeffML
Created October 30, 2017 00:19
Show Gist options
  • Save JeffML/d79ab5928dd9636f0d9d51ef5842061a to your computer and use it in GitHub Desktop.
Save JeffML/d79ab5928dd9636f0d9d51ef5842061a to your computer and use it in GitHub Desktop.
Using treeize to generate JSON heirarchies
import Treeize from 'treeize'
const treeized = rs => {
var authors = new Treeize();
const seed = rs.map(r => ({
name: [r.last_name, r.first_name].join(', '),
'categories:type': r.category,
'categories:titles:name': r.title
}))
authors.grow(seed);
return authors.getData();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment