Skip to content

Commit

Permalink
backport #346 fix for 2.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 16, 2013
1 parent 2a0c770 commit 7e10ce0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ protected final JsonNode deserializeAny(JsonParser jp, DeserializationContext ct
{
switch (jp.getCurrentToken()) {
case START_OBJECT:
case END_OBJECT: // for empty JSON Objects we may point to this
return deserializeObject(jp, ctxt, nodeFactory);

case START_ARRAY:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,56 @@
import java.math.BigDecimal;
import java.util.*;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

/**
* Additional tests for {@link ObjectNode} container class.
*/
public class TestObjectNode
extends BaseMapTest
{
private final ObjectMapper MAPPER = new ObjectMapper();
@JsonDeserialize(as = DataImpl.class)
public interface Data {
}

public static class DataImpl implements Data
{
protected JsonNode root;

@JsonCreator
public DataImpl(JsonNode n) {
root = n;
}

@JsonValue
public JsonNode value() { return root; }

/*
public Wrapper(ObjectNode n) { root = n; }
@JsonValue
public ObjectNode value() { return root; }
*/
}

/*
/**********************************************************
/* Test methods
/**********************************************************
*/

private final ObjectMapper MAPPER = objectMapper();

// for [Issue#346]
public void testEmptyNodeAsValue() throws Exception
{
Data w = MAPPER.readValue("{}", Data.class);
assertNotNull(w);
}

public void testBasics()
{
ObjectNode n = new ObjectNode(JsonNodeFactory.instance);
Expand Down

0 comments on commit 7e10ce0

Please sign in to comment.