Hello, in this tutorial, I will show you how to convert the Response String into a JSON object so you can extract contents from it in the blueprint.
Hello, in this tutorial, I will show you how to convert the Response String into a JSON object so you can extract contents from it in the blueprint.
Converting the Response into a JSON
To convert the Response String from the Make a HTTP Request node into a JSON object, make sure that the string is a JSON object.
Use the To JSON node and connect the Response String.
It returns a JSON object that we can then use any of these Get Nodes to get the data from the object.
Extracting the contents
Take a look at the example JSON string from the response:
The purchaseToken and orderId is a string, the purchaseTime time is most likely a number, and isValid is a boolean.
To get the purchaseToken or orderId, use the Get String node.
For the purchaseTime, use Get Number.
For the boolean, use Get Boolean.
Nested JSONs
Sometimes your JSON object may contain another JSON or an array of them like this:
To get them, use the Get Object or the Get Object Array nodes.
The contacts property is an array of JSON objects, so we need to use the Get Object Array node.
Once we have the array, we can use the For Each Loop node to iterate through all the ojbects.
The Array Element from the loop represents the JSON objects. We can then use the Get nodes to get the data from it.