-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using melt.js on nested json data #1
Comments
Correct it assumes you have a list of objects. Depending on which keys your are melting/casting the objects can be nested in some cases, but melt will only operate on the top level.
I'd be happy to support this use case for any particular nested json file - like the one in your gist. But per your stackoverflow question, I'm not sure I want a generic solution that could work on structures only known at runtime. So the programmer would either need to understand what the nested structure looked like or have code that figured that out external to melt. Does that distinction make sense? I think it would keep the complexity of melt limited to its core goals and a bit more maintainable. Although I'd entertain a more comprehensive PR 😃 Perhaps a place to start would be to think about the API. Maybe using JSONPath? If you could make a version of |
Thanks for considering this. The json structure that seems to be the most relevant to d3.js layouts is the one in that flare.json example that Mike Bostock uses everywhere:
where the key names describe the structure (node name, children) with some additional attributes. Here are some examples: Many json structures, including the one that I am working with, have data in the keys instead, which I don't think will work with a lot of these layouts. For the example in my gist, even if you were to support that particular json file, there is variation across json files. They have varying depths and varying nodes. These are being converted from complex XML files (but a lot of json that I have seen is similar to mine) So maybe this library isn't a good fit for this. But it does seem like d3 users would benefit from a library that can turn typical json files into d3 layout consumable json files. |
I tried melt.js on a complex json structure like this:
https://gist.github.com/jefffriesen/7325451
I got this error:
Uncaught TypeError: Object # has no method 'forEach' (line 43).
My guess is it doesn't work on nested data structures like this. If that is true, would that be something you would consider adding?
For more context, here is the stackoverflow question I am trying to solve to visualize an XML file with d3.js:
http://stackoverflow.com/questions/18425019/converting-xml-to-json-with-generic-keys-instead-of-element-names-as-keys
The text was updated successfully, but these errors were encountered: