Closed lxdvs closed 13 years ago
Sounds like a good idea. How do you think it should be specified? A "defaults" property to value dict? Or should it be part of props?
"props": {
"int": ["reviewCount"],
"double": ["distance"],
"Location": ["location"]
},
"defaults": {
"reviewCount": -1
}
vs
"props": {
"int": [["reviewCount", -1]],
"double": ["distance"],
"Location": ["location"]
}
I think a separate defaults section sticks to your basic theme of fields-in-blocks (similar to json_map or serializables).
Right now I believe the parser will default to defaulting to 0 when parsing nonexistent keys with optInt and optLong; it would be better if long and int parsing defaulted to -1. Double parsing already correctly defaults to NaN.
However, the best option would be if the fallback value were definable in the json.