neslib/Neslib.Json

JSON Path - Match error

vanillamasonry opened this issue · 3 comments

Hi,
The following JPATH example $.book[10].author will raise error if the child 10 do not exists.
I think that will be better to only return an empty array (no match) or at least to have the ability to check if the path exists before execution.
There is any way to check if path exists?

Thanks,
Paul

OK, I found a workaround using MatchSingle. It looks that is not raising any error if path do not exists.

Thanks,
Paul

@vanillamasonry Can you provide a code sample. I tried this code:

var Matches := TJsonPath.Match(Doc, '$.store.book[10].author');

But it doesn't raise any exceptions. It just returns no matches.

Closing issue for now because of lack of feedback. Feel free to reopen when you have more information.