JamesNK / Newtonsoft.Json

Json.NET is a popular high-performance JSON framework for .NET
https://www.newtonsoft.com/json
MIT License
10.71k stars 3.24k forks source link

`SelectToken` Uncaught Invalid JsonPath Format #2894

Closed mcgill-sfeng closed 12 months ago

mcgill-sfeng commented 12 months ago

Steps to reproduce

new JObject().SelectToken("example[0,:1]");

Expected behavior

Newtonsoft.Json.JsonException: 'Unexpected character while parsing path indexer: ;'

Actual behavior

No exception thrown. The function returns null.

mcgill-sfeng commented 12 months ago

After some research & reflection, I realize that this is actually valid as [0,:1] can be treated as [0, 0:1], and although this has a duplicate index 0, it doesn't go against the rules of Json Path per se.