I'm not sure where else we could put this code, but I think I might
have an idea.....
Right now we use JsonSerializer to output the Person objects that get
generate that code. That seemed to be the only place to put in this
optimization. however on second look it appears that we throw out
null values. So what we can do is change the logic of getIsOwner and
getIsViewer to only return Boolean.TRUE when true and null otherwise.
thoughts?
On Feb 17, 2009, at 6:26 PM, Louis Ryan wrote:
Paul
I dont think common is the correct place to put that code as it is
very
social API specific. Why not just change the model to use Boolean
instead of
boolean?
-Louis
On Tue, Feb 17, 2009 at 2:16 PM, <[email protected]> wrote:
Author: lindner
Date: Tue Feb 17 22:16:36 2009
New Revision: 745275
URL: http://svn.apache.org/viewvc?rev=745275&view=rev
Log:
SHINDIG-888 | Reduce json output for people requests only generate
isOwner/isViewer output if they are true.
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/
shindig/common/JsonSerializer.java
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/
shindig/common/JsonSerializer.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/JsonSerializer.java?rev=745275&r1=745274&r2=745275&view=diff
=
=
=
=
=
=
=
=
=
=====================================================================
---
incubator/shindig/trunk/java/common/src/main/java/org/apache/
shindig/common/JsonSerializer.java
(original)
+++
incubator/shindig/trunk/java/common/src/main/java/org/apache/
shindig/common/JsonSerializer.java
Tue Feb 17 22:16:36 2009
@@ -189,15 +189,20 @@
try {
Object value = entry.getValue().invoke(pojo);
if (value != null) {
- // Drop null values.
- if (firstDone) {
- buf.append(',');
- } else {
- firstDone = true;
+ String attribute = entry.getKey();
+
+ // Common use case isOwner/isViewer should not be set
unless
true
+ if (!((attribute.equals("isOwner") ||
attribute.equals("isViewer")) && value.equals(Boolean.FALSE))) {
+ // Drop null values.
+ if (firstDone) {
+ buf.append(',');
+ } else {
+ firstDone = true;
+ }
+ appendString(buf, attribute);
+ buf.append(':');
+ append(buf, value);
}
- appendString(buf, entry.getKey());
- buf.append(':');
- append(buf, value);
}
} catch (IllegalArgumentException e) {
// Shouldn't be possible.