Tinderbox Forum

Example of JSON parsing - Mars Rover pictures (v9.1+)

As mentioned in Saturday’s discussion of new features, here is a demo (by @eastgate) of JSON parsing:

What is does:
Fetches the most recent snapshots from NASA’s Mars Rover.

Techniques:

  • Using a stamp to customize a document — adding a prototype and setting up a container
  • Computing a query URL
  • Fetching JSON from a web service
  • Parsing that JSON to create new notes that auto fetch an image from NASA.

Look at: The Mars! stamp in the /Hints/Stamps

To try it yourself:

Apply the Mars! stamp to the Mars container

2 Likes

how about a function to create the /Mars container - so you could simply use delete("/Mars") to remove the container including all images and create a new, empty one on the fly. Should be faster than iterating through a list?!
But since you get an unique id for each image - maybe you should store those in a separate note and fetch only the new ones?
Still as a JSON demo it is perfect as it is :wink:

Feel free to imporve and upload your own version. Recall, these files were demos hacked out to help (beta test) users get a feel for the new functions and how they work. I’m sure (@eastgate is welcome to correct me!) that they weren’t written as 'best use examples.

Indeed if community members with the relevant skills can polish and improve the starting model, that’s great! If doing so, please explain what you’ve added/changed and as importantly why.

Let’s be community minded, improvement in this context isn’t a competition but both (a) an opportunity to contribute expertise others may not (yet) have and (b) a means to help others learn. Throughout my years of using computers and code most of my learning has come from the open-handed help of others rather than teaching and I’m keen to pay that generosity forward by helping others. :slight_smile:

In closing, in case it appears otherwise, this is not a critique of @webline’s post but just encouragement to use all to contribute. As well as better code, iIt’s also useful to hear from those who find examples too complex or lacking in hand-holds for learning. We don’t know what we don’t know! :slight_smile:

1 Like

See the training I just published. You can modify the functions to add a delete function.