Extracting JSON Value from 1 Liner Files

I’m trying to parse out the value of a specific json key. The below when running in qna works fine, shows the value as expected but only if the json file is formatted with multiple lines, see below. Know of how I can get the value when the json file is written to be a 1 liner?

values of keys “objectId” of jsons of files “path_to_file”

works if json is formatted as the below
{
“code”:200,
“objectId”:“vu9U3hXa3q0AAAABACNidWlsdGluOmFsZXJ0aW5nLm1haW50ZW5hbmNlLXdpbmRvdwAGdGVuYW50AAZ0ZW5hbnQAJGJkMThmOGUwLTcxM2MtMzBjZS04Zjg5LTg4MTQ0MTdmNmM1Nr7vVN4V2t6t”
}

1 line json, does not work here
[{“code”:200,“objectId”:“vu9U3hXa3q0AAAABACNidWlsdGluOmFsZXJ0aW5nLm1haW50ZW5hbmNlLXdpbmRvdwAGdGVuYW50AAZ0ZW5hbnQAJGY1ZTJmZDNhLWFlZmQtM2FhNy05Y2U2LTMzNjZlNTc1MTUyML7vVN4V2t6t”}]

These are different JSON values. Not just that it’s one line, but structurally they are different.

In the first, the beginning { tag indicates a single Dictionary item, while in the second the [{ indicates an array of dictionaries (but only one item in the array).

I’m away from computer now and can’t look it up, but I think you’ll need the ‘elements of’ property to loop through the array elements, something like

values of keys "objectId" of elements of jsons of files "path_to_file"

@JasonWalker BigFix ninja :slight_smile: this works perfectly, thank you!