Skip to content

Commit

Permalink
Improve empty result
Browse files Browse the repository at this point in the history
  • Loading branch information
shellac committed Mar 19, 2012
1 parent 88f98e8 commit 2efb9d2
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -58,6 +58,10 @@ public class RdfResourceMappingProvider
private final BiMap<Property, String> propertyToKey;
private final List<String> asArrays;

// '{"item":[]}' in bytes
private static final byte[] EMPTY_JSON_RESULT =
new byte[]{ 123, 34, 105, 116, 101, 109, 34, 58, 91, 93, 125 };

/**
* Create a provider (no array mapping)
*
Expand Down Expand Up @@ -165,7 +169,7 @@ public void writeTo(Object t, Class<?> type, Type type1, Annotation[] antns,
// Special case that I can't persuade the JSON writer to deal with
// (it writes [""])
if (resources.isEmpty() && mt.equals(MediaType.APPLICATION_JSON_TYPE)) {
out.write('['); out.write(']');
out.write(EMPTY_JSON_RESULT);
return;
}

Expand Down

0 comments on commit 2efb9d2

Please sign in to comment.