Hello, ( I apologize if this is duplicate message)
I noticed that if I have a bean that has primitive member with setters and getters and I try to instantiate it from JSON string that has invalid int for that member, EZ Morph is using default value 0 instead of throwing exceptions.
I looked at the code of EZMorpth and I could not find an easy way to change that default behavior. I would like to be able to differentiate between invalid value and default value. Is there some easy trick I can use to do so?
Thanks
Leonard

Hello, ( I apologize if this is duplicate message)
I noticed that if I have a bean that has primitive member with setters and getters and I try to instantiate it from JSON string that has invalid int for that member, EZ Morph is using default value 0 instead of throwing exceptions.
I looked at the code of EZMorpth and I could not find an easy way to change that default behavior. I would like to be able to differentiate between invalid value and default value. Is there some easy trick I can use to do so?
Thanks
Leonard

Hello,
I noticed that if I have a bean that has primitive member with setters and getters and I try to instantiate it from JSON string that has invalid int for that member, EZ Morph is using default value 0 instead of throwing exceptions.
I looked at the code of EZMorpth and I could not find an easy way to change that default behavior. I would like to be able to differentiate between invalid value and default value. Is there some easy trick I can use to do so?
Thanks
Leonard

Currently, json-lib will log a message at warn level if during the process of converting an object to json if finds a property descriptor without an attendant write method. See lines 362 and 698 of JSONObject:
log.warn( "Property '" + key + "' of "+ root.getClass()+" has no write method. SKIPPED." );
There are several valid, expected reasons why this condition might occur. For instance, it turns out that the javaassist classes created by Hibernate often run into this situation. Would you consider changing the log level to info for these statements? It seems a better fit for this particular condition:
http://en.wikipedia.org/wiki/Java_Logging_Frameworks#Level
What do you think?
Jonathan

It seems like it would be nice to have a convenience method to set
multiple bean processors on JsonConfig. There are ways to do so in
Spring using FactoryBean and Initializing bean, even though there is not
a normal setter like my convenience method below.
If it's not deemed generally useful, it could be added to the JsonView
for json-lib-ext-spring instead.
Here's the jdk15 version of what I'm thinking:
public void setJsonBeanProcessors(Map<Class, JsonBeanProcessor>
jsonBeanProcessors) {
Set<Class> classes = jsonBeanProcessors.keySet();
for (Iterator<Class> iterator = classes.iterator();
iterator.hasNext();) {
Class target = iterator.next();
registerJsonBeanProcessor(target, jsonBeanProcessors.get(target));
}
}
Then a convenience method coupld be added to delegate this in JsonView
to it's JsonConfig.
What do you think?
Paul Sundling