manishks12288 / jsonpath

Automatically exported from code.google.com/p/jsonpath
0 stars 0 forks source link

C#, Negative Phyton slice #27

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
parseInt does not allow negative numbers (NumberStyles.None), this prevents 
negative index selectors from working as expected. Personal fix was to use 
NumberStyles.AllowLeadingSign

eg. $.data[0].values[-1:].value would return all values in path 
$.data[0].values[*].value instead of expected values.

Original issue reported on code.google.com by korup...@gmail.com on 16 Dec 2013 at 10:08

GoogleCodeExporter commented 8 years ago
https://code.google.com/p/jsonpath/source/browse/trunk/src/cs/JsonPath.cs#263

I worked around this issue by changing NumberStyles.None to 
NumberStyles.AllowLeadingSign in the ParseInt method.

Original comment by l...@patorg.de on 20 May 2015 at 5:12

GoogleCodeExporter commented 8 years ago
Also, I would recommend to change int.Parse to TryParse, which is faster.
See also: http://stackoverflow.com/questions/467613/parse-v-tryparse

Original comment by l...@patorg.de on 20 May 2015 at 5:21

GoogleCodeExporter commented 8 years ago
Thanks for reporting this issue. Since Google Code is shutting[1] down soon, 
I've migrated the C# version and this issue over to GitHub[2]. Please 
subscribe, comment and/or send PR on issue #1[3] there for follow-up. Thanks!

[1] http://google-opensource.blogspot.ch/2015/03/farewell-to-google-code.html
[2] https://github.com/atifaziz/JSONPath
[3] https://github.com/atifaziz/JSONPath/issues/1

Original comment by azizatif on 27 Jun 2015 at 10:56