Locoia
Ask or search…
K
Links
Comment on page

Parsing JSONs from String

Some connectors and databases return JSON data in an escaped string that you can not use right away. Here an example:
{
"timestamp": 1657722582,
"information" : "{\"id\":\"0001\",\"type\":\"donut\",\"name\":\"Cake\",\"ppu\":0.55,\"active\":false}"
}
If you receive JSON data as a string that you like to convert into a JSON, you can use our dictionary helper.
If we assume that the data is stored in get_data the following code example will help you to parse the data in a way that it can be read as a JSON:
{{ get_data.information | replace('null', 'None') | replace('true', 'True') | replace('false', 'False') | replace('\\/', '/') }}
The result will be:
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"active": false
}