Hi,
I'm having great success with using JsonObject to map to static types in my interface layer. One thing is giving me a headache, though. My objects have a number of fields that may be omitted from the JSON that goes over the wire. In these cases, I can't do this:
if( myObject.something != null) {
doSomethingWithIt();
}
because of the exception. I have to wrap all those with:
try {
if(myObject.something !+ null) { doSomethingWithIt(); }
} catch (NoSuchMethodException) {
}
It's kind of messy, and I'm looking for a better way. I considered making non-existing objects default to null by extending JsonObject.
What do others do with sparse json objects with lots of optional fields?
--Chris