-
Notifications
You must be signed in to change notification settings - Fork 6
Module 2C: IMDB Data (Parsing)
So now that we have all this JSON data, how do we make it useful? We tell Refine to parse the data with this raw GREL expression:
value.parseJson()["element"]
JSON is returned as an array of data. Unformatted JSON data looks messy, but when it's properly formatted, it looks like this:
Each of those lines of the array represent a metadata element which has a data value. So, to parse out what language is spoken in each of each these visual works, we would use the GREL command
value.parseJson()["Language"]
Thus, the OMDB data is not at all complicated. Complicated JSON would have more elements nested under each other. For example, asking the Google Maps API for data on the address of Rice University in Houston returns data nested like this:
To parse out the southwest latitude point of these coordinates, we would need to use a GREL command that searches all the way down to the element we want:
value.parseJson()["results"]["geometry"]["bounds"]["southwest"]["lat"]
Let's try parsing our data for writers. On the JSON column, select Edit Column > Add Column Based on This Column. Let's call the new column 'Writers' and use this GREL:
value.parseJson()["Writer"]
(Remember: parsing JSON elements is case-sensitive! make sure the element(s) matches what's in the data exactly.)
Now let's do the same for Directors and Actors. When finished, you should have three columns of parsed data.