Jack Allan
Jack Allan

Reputation: 15004

Get root object using JSONPath query

Is there any syntax for a json path query to return the root object?

To quote Goessner on the subject:

Since a JSON structure is usually anonymous and doesn't necessarily have a "root member object" JSONPath assumes the abstract name $ assigned to the outer level object.

So I'd really expect just "$" to return the root object... But it doesn't. It returns false.

I need a way to get the root object in a query (seems silly I know but the application I am using only allows me to specify a jsonpath query to access items in JSON).

Upvotes: 1

Views: 8813

Answers (1)

glytching
glytching

Reputation: 47905

$ does return the root object for Jayway, Gatling and Nebhale.

Looks like the equivalent in Goessner is $..

Upvotes: 5

Related Questions