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
Currently, Any API returns .get(...) calls with default values if the specified JSON path does not exist. Consider:
String input = '{ "id": 35, "name": "Agatha", "surname": "Christie" }';
Any any = JsonIterator.deserialize(input);
System.out.println(any.get("age").toInt()); --> prints "0"
Instead of returning some default values ("" for String, 0 for int, etc.), do you think it's sane to have the .get method like this?
Any.get(Object defaultValue, Object... keys)
So we could do this:
String input = '{ "id": 35, "name": "Agatha", "surname": "Christie" }'; Any any = JsonIterator.deserialize(input); System.out.println(any.get(26, "age").toInt()); --> Since "age" key doesn't exist, will print 26
The text was updated successfully, but these errors were encountered:
Currently, Any API returns .get(...) calls with default values if the specified JSON path does not exist. Consider:
String input = '{ "id": 35, "name": "Agatha", "surname": "Christie" }';
Any any = JsonIterator.deserialize(input);
System.out.println(any.get("age").toInt()); --> prints "0"
Instead of returning some default values ("" for String, 0 for int, etc.), do you think it's sane to have the .get method like this?
Any.get(Object defaultValue, Object... keys)
So we could do this:
String input = '{ "id": 35, "name": "Agatha", "surname": "Christie" }'; Any any = JsonIterator.deserialize(input); System.out.println(any.get(26, "age").toInt()); --> Since "age" key doesn't exist, will print 26
The text was updated successfully, but these errors were encountered: