I am doing some work with a number of different api’s, each of which return relatively large, nested JSON files. At the moment, I step through the file by doing something like
Data[[1]] etc.,
However, this seems very clunky, and I am sure there must be a function which lets me understand the structure much more quickly.
So, I am hoping someone with more experience can explain how they tackle the problem.
In this particular case, I am Importing[] the files, just because I had downloaded them locally.
Typically, the files have a number of JSON keys describing things like version numbers, license requirements etc., and then there is a ‘data’ key (although the name is often different) with a large list of lists that contain the parts I am really interested in.
My question is whether there is a simple way of visualising the structure when you know nothing about the file. I was wondering if I could perhaps display the keys as a tree plot of some kind, or maybe there is a way to show the structured as an indented list. There are a number of web based tools that can do this sort of thing, and I was hoping that Mathematica had a similar function.
I don’t know if that’s the kind of thing you’re looking for. Also, once you’ve imported the data and have an Association, you can use the association-related functions (e.g. Keys).
Oh, that’s brilliant! It’s exactly what I was looking for. I think the problem was that Import brought the file in as JSON, and I should have forced it to RawJSON.