neslib / Neslib.Json

Fast and memory-efficient JSON for Delphi
Other
79 stars 23 forks source link

JPath unable to escape "." #8

Closed vanillamasonry closed 3 years ago

vanillamasonry commented 3 years ago

Hi,

How can I escape "." in the front/ end of an element?

I have the following JSON: { "error_summary": "expired_access_token/", "error": { ".tag": "expired_access_token" } }

I need to select ".tag" using JPath using https://jsonpath.com/ I select the element with $.error.['.tag'] Using Neslib.Json I have the following error "Child operator in JSON path is missing a member name"

Thank you in advance,

neslib commented 3 years ago

You should remove the second period (after "error"). So the correct expression is $.error['.tag'] instead of $.error.['.tag'].

I am using the (unofficial) specification from https://goessner.net/articles/JsonPath/. It says that a child operator is either a period followed by a name (as in .error) or a name in square brackets (as in ['.tag']).

In your example you use both at the same time. The jsonpath.com site seems to accept this, but my parser follows the rules more strictly.

Hope this helps.

vanillamasonry commented 3 years ago

Thanks again, https://jsonpath.com/ misled me.