You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
The inner class MaxSegment and MinSegment in JSONPath has a bug.
e.g. 1 there is a JSONString like this: { 'id' : 0, 'items' : [ {'name': 'apple', 'price' : 30 }, {'name': 'pear', 'price' : 40 } ] }
the Path String as this: $.items[*].price.max()
exactly it should be "40" but throw a UnsupportedOperationException.
e.g. 2 when the path string change to $.items[*].price.size() , I got a correct result as "2".
so, I read the source codes like this:
` static class SizeSegment implements Segment {
public final static SizeSegment instance = new SizeSegment();
public Integer eval(JSONPath path, Object rootObject, Object currentObject) {
return path.evalSize(currentObject);
}
public void extract(JSONPath path, DefaultJSONParser parser, Context context) {
throw new UnsupportedOperationException();
}
}`
`static class MaxSegment implements Segment {
public final static MaxSegment instance = new MaxSegment();
public Object eval(JSONPath path, Object rootObject, Object currentObject) {
Object max = null;
if (rootObject instanceof Collection) {
Iterator iterator = ((Collection) rootObject).iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
if (next == null) {
continue;
}
if (max == null) {
max = next;
} else if (compare(max, next) < 0) {
max = next;
}
}
} else {
throw new UnsupportedOperationException();
}
return max;
}
public void extract(JSONPath path, DefaultJSONParser parser, Context context) {
throw new UnsupportedOperationException();
}
}`
In class SizeSegment,the eval function use "currentObject" , it was $.items[*].price .
In class MaxSegment and MinSegment , they use "rootObject" , it was $.
so, Is it a bug?
The text was updated successfully, but these errors were encountered:
The inner class MaxSegment and MinSegment in JSONPath has a bug.
e.g. 1 there is a JSONString like this:
{ 'id' : 0, 'items' : [ {'name': 'apple', 'price' : 30 }, {'name': 'pear', 'price' : 40 } ] }
the Path String as this:
$.items[*].price.max()
exactly it should be "40" but throw a UnsupportedOperationException.
e.g. 2 when the path string change to
$.items[*].price.size()
, I got a correct result as "2".so, I read the source codes like this:
` static class SizeSegment implements Segment {
`static class MaxSegment implements Segment {
In class SizeSegment,the eval function use "currentObject" , it was
$.items[*].price
.In class MaxSegment and MinSegment , they use "rootObject" , it was
$
.so, Is it a bug?
The text was updated successfully, but these errors were encountered: