Skip to content

Commit

Permalink
Implement #403 ("Make JsonNode work with XML")
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 21, 2020
1 parent 56d3f0c commit 612b2ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.fasterxml.jackson.dataformat.xml.deser;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;

public class JsonNodeDeser403Test extends XmlTestBase
{
final private ObjectMapper MAPPER = newMapper();

public void testSimpleNode() throws Exception
{
JsonNode root = MAPPER.readTree("<root attr='123' />");
assertTrue(root.isObject());
assertEquals(1, root.size());
assertEquals("123", root.get("attr").textValue());
}

// [dataformat-xml#403]: Allow sequences
public void testRepeated() throws Exception
{
JsonNode root = MAPPER.readTree("<root><value>a</value><value>b</value></root>");
assertTrue(root.isObject());
JsonNode arr = root.get("value");
assertEquals(JsonNodeType.ARRAY, arr.getNodeType());
assertTrue(arr.isArray());
assertEquals(2, arr.size());
assertEquals("a", root.at("/value/0").asText());
assertEquals("b", root.at("/value/1").asText());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.dataformat.xml.failing;
package com.fasterxml.jackson.dataformat.xml.lists;

import java.util.*;

Expand Down

0 comments on commit 612b2ac

Please sign in to comment.