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
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