Dig 1 layer deeper into JSON using Formulas

Hi, I’m trying to parse some JSON that arrives like this:

{"1643922182830":{"bestPrinciple":"5","timestamp":1643922182830}}

I want the bestPrinciple and timestamp values but can’t get past the 1st layer of JSON to actually access these values, so my variables end up as null and undefined. There’s no way this is difficult to do, I just can’t seem to find the right formula function or whatever.

Alright I solved it but it’s a bit messy. First I set a page variable of “key” to store the first key of the JSON data:

KEYS(outputs["HTTP request"].resBodyParsed)[0]

Then I pass that key into a Formula and do a LOOKUP to get the data:

LOOKUP(outputs["HTTP request"].resBodyParsed, pageVars.key).bestPrinciple

You might be better off simply storing the JSON as an Object, which you can then access in the functions as myObject.level1.level2.level3.whatever

1 Like