How to use Object Path, the agile query languge, to effectively extract relevant data from JSON documents of complex or even unknown structure. How to quickly build a web app using the insights you discover with ObjectPath.
2. What is JSON?
JSON (JavaScript Object Notation) is:
• a lightweight data-interchange format
• easy for humans to read and write
• easy for machines to parse and generate
3. What does JSON look like?
JSON is built on two structures:
•An object – a collection of name/value pairs
{ "firstName":"John" , "lastName":"Doe" }
•An array - an ordered list of values
[
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
4. What does JSON look like?
A value can be:
• a string in double quotes: “a string”
• a number: 22
• true or false!
• null
• an object: {}
• an array: []
These structures can be nested.
5.
6. Why did we build ObjectPath?
• The combination of objects and arrays allows for
simple, human-readable representation of all
kinds of real life objects
• BUT using JSON's full potential is impossible
without an easy way to query complex structures
• In real life data you deal with is messy
8. Getting started with ObjectPath
git clone https://github.com/adriank/ObjectPath.git
cd ObjectPath/ObjectPathPy
./ObjectPath.py -u “https://gdata.youtube.com/feeds/api/
videos?q=football&orderby=published&start-
index=1&max-results=50&alt=json"
!
(Warning: In China YouTube API doesn’t work without VPN!)
9. Data we'll work with today
• Klout API
• YouTube API
• Big geospatial data file from San Francisco
(182MB)
• Your own datasets are welcomed!
10. Klout API
What is the nickname of the person with the highest Klout score that
influences Guy Kawasaki?
• $.*
• max($..score)
• $..*[@.score is max($..score).score]
• $..*[@.score.score is max($..score).score]
• $..*[@.score.score is max($..score).score].nick
• $.myInfluencers..*[@.score.score is
max($.myInfluencers..score).score].nick[0]
11. YouTube API
• ./ObjectPath.py -u “https://gdata.youtube.com/feeds/api/
videos?q=football&orderby=published&start-index=1&max-
results=50&alt=json"
• $.*
• $..entry[0].link
• $..*[@.title['$t'] is "FIFA 14 | Fails Compilation May
2014!"]..link[@.type is "text/html"][0].href
12. CityLots data from SF
• Calculating the area of a lots in SF
• https://data.sfgov.org/Other/Data-Catalog/h4ui-
ubbu
• We’ll work with data converted to JSON from:
https://github.com/zeMirco/sf-city-lots-json
• git clone https://github.com/zeMirco/sf-city-lots-
json.git
13. How to build a YT search
web app in 10 min?
http://adrian.ap.asyncode.com/index.html#!main=yt/default&ds=/yt/default/fifa