Skip to content

Commit

Permalink
Fix #18 by reverting #16
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 3, 2020
1 parent 3aa4b12 commit 4c87d57
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Project: jackson-datatype-jsr353
=== Releases ===
------------------------------------------------------------------------

2.10.5 (not yet released)

#18: revert #16 as it can cause issues if target type is `JsonObject`
(reported by sithmein@github)

2.10.4 (03-May-2020)

#16: Null being deserialized as null literal instead of JsonValue.NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ public JsonValue deserialize(JsonParser p, DeserializationContext ctxt)
}
}

// 02-Jun-2020, tatu: Alas, as per [#18], can not do quite like so...
/*
@Override
public JsonValue getNullValue(final DeserializationContext ctxt) {
return JsonValue.NULL;
}
*/

@Override
public Object deserializeWithType(JsonParser p, DeserializationContext ctxt,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.fasterxml.jackson.datatype.jsr353;

import javax.json.JsonObject;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;

public class DeserViaCreatorTest extends TestBase
{
static class Pojo {
String text;
JsonObject object;

@JsonCreator
public Pojo(@JsonProperty("s") String s, @JsonProperty("o") JsonObject o) {
text = s;
object = o;
}
}

public void testCreatorDeser() throws Exception
{
final ObjectMapper mapper = new ObjectMapper()
.registerModule(MODULE);
Pojo p = mapper.readerFor(Pojo.class)
.readValue( "{\"s\": \"String\", \"o\": { \"a\": 1, \"b\": \"2\" } }");
assertNotNull(p);

p = mapper.readerFor(Pojo.class).readValue("{\"s\": \"String\"}");
assertNotNull(p);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ public void testBinaryNode() throws Exception
}

// for [datatype-jsr353#16]
// 02-Jun-2020, tatu: Alas, as per [#18], can not do quite like so...
/*
public void testNullNode() throws Exception
{
final String serializedNull = MAPPER.writeValueAsString(JsonValue.NULL);
assertEquals("null", serializedNull);
final JsonValue deserializedNull = MAPPER.readValue(serializedNull, JsonValue.class);
assertEquals(JsonValue.NULL, deserializedNull);
}
*/
}

0 comments on commit 4c87d57

Please sign in to comment.