The parsing is based on this surprisingly short functional parsing library by Graham Hutton (also seen on Computerphile). Turns out monads are useful for something.
Let’s say we wanted to check out some of that data. If we
curl the API endpoint with a
GET request, we get back a huge JSON object. We can save this object to
curl https://ssd-api.jpl.nasa.gov/sentry.api > impact_data.json
We can then pipe the JSON into the processor a give it a filter, such as getting the length of the data array containing the objects:
cat data.json | jq-clone '.data | length'
Right now that returns a length of 1581. What if we want to know something more complicated, like whether any of the projected cumulative impact probabilities are larger than 1%?
cat data.json | jq-clone '[.data.ip | tonumber | . > 0.01]'
Interestingly enough that returns true, and it turns out that there are 2 objects right now that have a larger than 2% probability of impacting Earth within a couple hundred years. We can see the exact range of years during which this could occur by checking out the range field for each object:
cat data.json | jq-clone '.data.range'
Overall this was a great way to learn functional programming while also learning about a neat tool.