ibatullin / jsonpath_goessner

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

C#, Negative Phyton slice #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 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 9 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 9 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