[ 
https://issues.apache.org/jira/browse/SHINDIG-451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12614584#action_12614584
 ] 

Andres Almiray commented on SHINDIG-451:
----------------------------------------

Yes, you can filter out properties with SF JSON in several ways:
1) defining a exclusion list in JsonConfig.setExcludes(String[])
2) registering a JsonBeanProcessor (which is a custom POJO serializer)
3) registering a PropertyFilter with jsonConfig.setJsonPropertyFilter()

I believe you are looking for option #3 because it takes into account the value 
of the property
(http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/util/PropertyFilter.html)
The following filter fill skip adding any null property into the resulting 
JSONObject

JsonConfig jsonConfig = new JsonConfig()
jsonConfig.setJsonPropertyFilter( new PropertyFilter() {
   public void apply( Object source, String name, Object value ) {
      return value == null // if true then source.name will be filtered out
   }
})
JSON json = JSONObject.fromObject( jsonStr, jsonConfig )

Regarding performance, it is understandable from the point of view that SF JSON 
does more than ORG JSON when serializing back and forth between Java and JSON, 
still performance is still a key issue and efforts have been made to improve it.

> JSON Serialization using net.sf.json-lib
> ----------------------------------------
>
>                 Key: SHINDIG-451
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-451
>             Project: Shindig
>          Issue Type: Improvement
>          Components: OpenSocial  feature (Javascript), RESTful API (Java)
>            Reporter: Ian Boston
>         Attachments: SHINDIG-451.patch
>
>
> Progress on a patch to use json-lib to perform serialization of the inbound 
> and outbound json messages, at the moment it re-uses the rhino from Shindig 
> 412, but only in the tests to give finer grain control in the test cases. The 
> Enum handling in json-lib is neat :).
> The unit tests that are not currently working are disabled with a Xtest, but 
> Person and activity with some depth in the tree are working.
> Will attache the patch in a moment.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to