Fri 19 Oct 2007
Its just been a couple of days after Json-lib 2.1 was released and feature requests are already pouring in. The first one ask for custom handling of default values when a null reference is encountered. Per the JSON spec if a value is null Json-lib applies the following rules
The second feature caught me by surprise as I didn't understand the usefulness of it at first sight, the thing is that a user has a bean which uses a composed Map for its property representation, but that bean does not implements Map nor it is a DynaBean, so he would like to call internalMap.put() instead of going to trough the usual
These features have a default implementation already plugged into JsonConfig, which is the place where you would also plug-in your custom implementations.
The third one is related to JSON <-> serialization. As you may probably know, XMLSerializer will output type hints (unless configured otherwise) to an XML string, using those hints again when transforming back to JSON. The hints use reserved keywords as attributes [type,class,params,null] but it may be the case for some users that some of those keywords must have business meaning instead of just 'framework' meaning, how do we cope with that? by adding a 'json_' prefix to the reserved keywords. In order to maintain backward compatibility there is a flag on XMLSerializer (typeHintsCompatibility) that when set to
The code is already on the cvs along with a couple of quick bug fixes. Keep posted for more Json-lib updates.
features json json-lib xml
0 - if it is a Number or primitive number '' - if it is a String/Character or char false - if it is a Boolean null - all other cases
But what if you would like to return 'null' if an Integer reference is null? (yes I know that would against the spec), or if a MyCoolBean reference is null you'd like to return '{ empty: true }' instead of simply 'null'? that's the reason why DefaultValueProcessor is now available, along with DefaultValueProcessorMatcher (for the same reasons shown here).The second feature caught me by surprise as I didn't understand the usefulness of it at first sight, the thing is that a user has a bean which uses a composed Map for its property representation, but that bean does not implements Map nor it is a DynaBean, so he would like to call internalMap.put() instead of going to trough the usual
PropertyUtils.setProperty(), which depending on the client code can be sometimes a performance bottleneck. After a quick message exchange and a prompt patch PropertySetStrategy is ready.These features have a default implementation already plugged into JsonConfig, which is the place where you would also plug-in your custom implementations.
The third one is related to JSON <-> serialization. As you may probably know, XMLSerializer will output type hints (unless configured otherwise) to an XML string, using those hints again when transforming back to JSON. The hints use reserved keywords as attributes [type,class,params,null] but it may be the case for some users that some of those keywords must have business meaning instead of just 'framework' meaning, how do we cope with that? by adding a 'json_' prefix to the reserved keywords. In order to maintain backward compatibility there is a flag on XMLSerializer (typeHintsCompatibility) that when set to
false will enable the prefix, when true it will disregard it.The code is already on the cvs along with a couple of quick bug fixes. Keep posted for more Json-lib updates.
features json json-lib xml
About me











![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Fresources%2Fa%2Faalmiray%2Fimtd4.gif)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Fresources%2Fa%2Faalmiray%2Frss_weblogs.gif)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.blogburst.com%2FResources%2FImages%2Fblogburst_80x15.gif%3Fid%3DB8FvOsgxNdOKCYKtvrW8bRD)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.javablogs.com%2Fimages%2Fjavablog-small.gif)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Fresources%2Fa%2Faalmiray%2Fgroovyblogs_80x15.png)

Save This Page
![Save to furl [image]](http://mowser.com/img?url=http%3A%2F%2Fblogs.sun.com%2Froller%2Fresources%2Ftheaquarium%2F%2Ffurl.png)
![2 Comments [image]](http://mowser.com/img?url=http%3A%2F%2Fblogs.sun.com%2Froller%2Fresources%2Ftheaquarium%2F%2FcommentAdded.gif)
![No Comments [image]](http://mowser.com/img?url=http%3A%2F%2Fblogs.sun.com%2Froller%2Fresources%2Ftheaquarium%2F%2Fcomment.gif)
