Skip to content

Commit

Permalink
Backport #16 fix to 2.10(.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 4, 2020
1 parent 8b255c7 commit dc6a7b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.fasterxml.jackson.datatype.jsr353;

import com.fasterxml.jackson.databind.JsonMappingException;
import java.io.IOException;

import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonBuilderFactory;
import javax.json.JsonObjectBuilder;
Expand All @@ -28,7 +26,7 @@ public JsonValueDeserializer(JsonBuilderFactory bf) {

@Override
public JsonValue deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException
throws IOException
{
switch (p.getCurrentToken()) {
case START_OBJECT:
Expand All @@ -41,14 +39,13 @@ public JsonValue deserialize(JsonParser p, DeserializationContext ctxt)
}

@Override
public Object getNullValue(final DeserializationContext ctxt){
public JsonValue getNullValue(final DeserializationContext ctxt) {
return JsonValue.NULL;
}

@Override
public Object deserializeWithType(JsonParser p, DeserializationContext ctxt,
TypeDeserializer typeDeser)
throws IOException, JsonProcessingException
TypeDeserializer typeDeser) throws IOException
{
// we will always serialize using wrapper-array; approximated by claiming it's scalar
return typeDeser.deserializeTypedFromScalar(p, ctxt);
Expand All @@ -61,7 +58,7 @@ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt,
*/

protected JsonValue _deserializeObject(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException
throws IOException
{
JsonObjectBuilder b = _builderFactory.createObjectBuilder();
while (p.nextToken() != JsonToken.END_OBJECT) {
Expand Down Expand Up @@ -125,7 +122,7 @@ protected JsonValue _deserializeObject(JsonParser p, DeserializationContext ctxt
}

protected JsonValue _deserializeArray(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException
throws IOException
{
JsonArrayBuilder b = _builderFactory.createArrayBuilder();
JsonToken t;
Expand Down Expand Up @@ -177,7 +174,7 @@ protected JsonValue _deserializeArray(JsonParser p, DeserializationContext ctxt)
}

protected JsonValue _deserializeScalar(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException
throws IOException
{
switch (p.getCurrentToken()) {
case VALUE_EMBEDDED_OBJECT:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fasterxml.jackson.datatype.jsr353;

import com.fasterxml.jackson.databind.json.JsonMapper;
import javax.json.*;
import javax.json.JsonValue.ValueType;

Expand Down Expand Up @@ -84,7 +83,7 @@ public void testNestedObject() throws Exception
assertEquals(JSON, serializeAsString(v));
}

// for [issue#5]
// for [datatype-jsr353#5]
public void testBinaryNode() throws Exception
{
ObjectNode root = MAPPER.createObjectNode();
Expand All @@ -99,18 +98,12 @@ public void testBinaryNode() throws Exception
assertEquals("AA==", str); // single zero byte
}

// for [datatype-jsr353#16]
public void testNullNode() throws Exception
{
final JsonMapper mapper = mapperBuilder().build();

final String serializedNull = mapper.writeValueAsString(JsonValue.NULL);

final String serializedNull = MAPPER.writeValueAsString(JsonValue.NULL);
assertEquals("null", serializedNull);

final JsonValue deserializedNull = mapper.readValue(serializedNull, JsonValue.class);

assertNotNull(deserializedNull);

final JsonValue deserializedNull = MAPPER.readValue(serializedNull, JsonValue.class);
assertEquals(JsonValue.NULL, deserializedNull);
}
}

0 comments on commit dc6a7b4

Please sign in to comment.