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
I just checked it out, the length method has been overridden in some of the classes without providing implementation for String length like GsonJsonProvider.class
@Override
public int length(final Object obj) {
if (isArray(obj)) {
return toJsonArray(obj).size();
} else if (isMap(obj)) {
return toJsonObject(obj).entrySet().size();
} else {
if (obj instanceof JsonElement) {
JsonElement element = toJsonElement(obj);
if (element.isJsonPrimitive()) {
return element.toString().length();
}
}
}
throw new JsonPathException("length operation can not applied to " + (obj != null ? obj.getClass().getName()
: "null"));
}
and it totally depends on which file you are using, for instance these classes does implement it supporting the String length.
JsonOrgJsonProvider implements it providing the String length.
JsonSmartJsonProvider (this one does not override it).
JettisonProvider implements the String length
this is the path where you can find the other implementations for this Abstract Class
Length function can not calculate String's length.
but in AbstractJsonProvider class can calculate String's path.
Why?
The text was updated successfully, but these errors were encountered: