Skip to content
  • Protopie and Figma
  • Protopie Tips
  • Experience Prototyping
  • Protopie and Figma
  • Protopie Tips
  • Experience Prototyping

PROTOPIE

parseJson gives no error message

parseJson can only return a node at the bottom of the JSON structure and cannot return an object – which means it is very important that you know the structure of your JSON and that it doesn’t vary.

Also, it is important to construct your request string very carefully as there are no error messages returned to tell you you have got it wrong. The solution to this is to find a way to check whether parseJson has returned “” and if it has, do something to alert you (change the colour of an object, for example).

Another common mistake is to use the indices, 1, 2, 3 etc when something has multiple values – whereas in fact parseJson uses the indices 0,1,2 etc. Thus, in my quiz with ten questions (which pulls data from a trivia API), I use the indices 1-10 to represent each instance of the question component (in a variable called “Identity”), but in the extraction of the question from the data returned from the API I have to use the index “Identity”-1.

Here is a pie which allows you to explore how sources and keys work with parseJson – it contains some simple examples, but you can edit the fields to try your own values – select the source style and then type the key and enter (or hit go).

Potentially related posts ...

Working with Components
more ...
Moving between Figma and Protopie
more ...
Rough, Rapid, Right
more ...
Arrays and multiple parameters
Protopie seems limited since a message can be sent using only one value as a parameter. However, arrays (written as text strings and manipulated by parseJson) can be used for contexts where multiple parameters need to be passed.
more ...

© 2023: David J Gilmore