Re: [json-lib-user] Is it possible to force JSONObject.toBean() throw exceptions on cast issues for
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2009-05-01 19:05:56
|
Hi Leonard, Yes, you can register a DefaultValueProcessor to do just that. http://json-lib.sourceforge.net/advanced.html http://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObject.html#812 http://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObject.html#833 Cheers, Andres ------------------------------------------- http://jroller.com/aalmiray http://www.linkedin.com/in/aalmiray -- What goes up, must come down. Ask any system administrator. There are 10 types of people in the world: Those who understand binary, and those who don't. To understand recursion, we must first understand recursion. ________________________________ From: Leonard Gestrin <lge...@gm...> To: jso...@li... Sent: Thursday, April 30, 2009 8:15:13 PM Subject: [json-lib-user] Is it possible to force JSONObject.toBean() throw exceptions on cast issues for primitives as oppose to using default values? 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 |