Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ignoring values

  • Loading branch information...
commit 3de802a06e2644651f261e0740e367a3bc65febf 1 parent ed53829
Johannes Schneider authored
12 jackson/src/main/java/com/cedarsoft/serialization/jackson/IgnoringSerializer.java
@@ -29,6 +29,12 @@ public void serialize( @Nonnull JsonGenerator serializeTo, @Nonnull Void object,
29 29 @Override
30 30 public Void deserialize( @Nonnull JsonParser deserializeFrom, @Nonnull Version formatVersion ) throws IOException, VersionException, JsonProcessingException {
31 31 JsonToken inToken = deserializeFrom.nextToken();
  32 +
  33 + if ( isValueToken( inToken ) ) {
  34 + return null;
  35 + }
  36 +
  37 +
32 38 JsonToken outToken = findOutToken( inToken );
33 39
34 40 int depth = 1;
@@ -47,8 +53,12 @@ public Void deserialize( @Nonnull JsonParser deserializeFrom, @Nonnull Version f
47 53 return null;
48 54 }
49 55
  56 + private static boolean isValueToken( @Nonnull JsonToken inToken ) {
  57 + return inToken.name().startsWith( "VALUE_" );
  58 + }
  59 +
50 60 @Nonnull
51   - private JsonToken findOutToken( @Nonnull JsonToken inToken ) {
  61 + private static JsonToken findOutToken( @Nonnull JsonToken inToken ) {
52 62 switch ( inToken ) {
53 63 case START_OBJECT:
54 64 return JsonToken.END_OBJECT;
3  jackson/src/test/java/com/cedarsoft/serialization/jackson/IgnoringSerializerTest.java
@@ -41,7 +41,8 @@ public void testIt( @Nonnull String json ) throws Exception {
41 41 "[1,2,3,4]",
42 42 "{\"id\":123}",
43 43 "{\"id\":[123]}",
44   - "{\"id\":{\"value\":123}}"
  44 + "{\"id\":{\"value\":123}}",
  45 + "\"\""
45 46 };
46 47 }
47 48 }

0 comments on commit 3de802a

Please sign in to comment.
Something went wrong with that request. Please try again.