JSONPath - pull first item only

Anybody know the syntax to pull the first object before the comma vs. it pulling the entire object which is a duplicate of the first one?

The error I’m getting:

JsonPath expressions with more than one result are only supported for Boolean, Number and String data types, please adapt your selector.

Here’s my syntax :

var String Temp7 = ‘NULL’
Temp7 = transform(“JSONPATH”, “$…NWSheadline”, results7.toString())

[
[
“WIND ADVISORY IN EFFECT FROM 4 PM FRIDAY TO 1 AM CDT SA TURDAY… …HIGH WIND WATCH IN EFFECT FROM SATURDAY MORNING THROUGH SATURDAY AF TERNOON”
],
[
“WIND ADVISORY IN EFFECT FROM 4 PM FRIDAY TO 1 AM CDT SA TURDAY… …HIGH WIND WATCH IN EFFECT FROM SATURDAY MORNING THROUGH SATURDAY AF TERNOON”
]
]

Best, Jay

Try "$.[0][0]"

This is closer now → $…NWSheadline[0]

Looks like it removed the duplicate brackets with the comma and clumped the duplicate entries together. I believe this duplicate entry was created by mistake on their end.

[
“WIND ADVISORY IN EFFECT FROM 4 PM FRIDAY TO 1 AM CDT SA TURDAY… …HIGH WIND WATCH IN EFFECT FROM SATURDAY MORNING THROUGH SATURDAY AF TERNOON”,
“WIND ADVISORY IN EFFECT FROM 4 PM FRIDAY TO 1 AM CDT SA TURDAY… …HIGH WIND WATCH IN EFFECT FROM SATURDAY MORNING THROUGH SATURDAY AF TERNOON”
]

Best, Jay

So, the quoted text isn’t the full JSON?
I’m pretty sure that $... is the source of the problem.
Two dots will select one or more nodes of data, so when there is more than one descendant with name NWSheadline, you will get more than one value.

use

var firstElement = JSON.parse(temp7)[0];

What is the original string, so that we can build the command without transform?

Please use proper code fences. Otherwise quotation marks are being converted.

Thank you Udo, I didn’t know that. Here’s how I got the correct path now. This is the path to the National Weather Service Alerts for my zone.

$.features[0].properties.headline

Used JSON Parser Online to parse JSON to get the path then used JSONPath Online Evaluator to validate the path.