There is a way working for some implementations of JsonPath:
$[0]firstName
Returns just "Joe"
instead of ["Joe"]
. Tested on the Jayway JsonPath online simulator.
It is kinda hard-coding the solution by providing the exact spot of the element with [0]
which defeats the purpose of jsonPath but as I understand your problem is very specific and you expect only one element from this query, otherwise you would want to store multiple elements in an array.
While this solution might work on some versions and implementations of JsonPath I strongly advise against it since JsonPath isn't meant to return any result that can't be later used for another JsonPath query. That's why the default queries will always return an array, because an array is a valid JSON document, while a single element isn't.