Skip to content

Commit 612b2ac

Browse files
committed
Implement #403 ("Make JsonNode work with XML")
1 parent 56d3f0c commit 612b2ac

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fasterxml.jackson.dataformat.xml.deser;
2+
3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import com.fasterxml.jackson.databind.node.JsonNodeType;
6+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
7+
8+
public class JsonNodeDeser403Test extends XmlTestBase
9+
{
10+
final private ObjectMapper MAPPER = newMapper();
11+
12+
public void testSimpleNode() throws Exception
13+
{
14+
JsonNode root = MAPPER.readTree("<root attr='123' />");
15+
assertTrue(root.isObject());
16+
assertEquals(1, root.size());
17+
assertEquals("123", root.get("attr").textValue());
18+
}
19+
20+
// [dataformat-xml#403]: Allow sequences
21+
public void testRepeated() throws Exception
22+
{
23+
JsonNode root = MAPPER.readTree("<root><value>a</value><value>b</value></root>");
24+
assertTrue(root.isObject());
25+
JsonNode arr = root.get("value");
26+
assertEquals(JsonNodeType.ARRAY, arr.getNodeType());
27+
assertTrue(arr.isArray());
28+
assertEquals(2, arr.size());
29+
assertEquals("a", root.at("/value/0").asText());
30+
assertEquals("b", root.at("/value/1").asText());
31+
}
32+
}

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser399Test.java renamed to src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser399Test.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.dataformat.xml.failing;
1+
package com.fasterxml.jackson.dataformat.xml.lists;
22

33
import java.util.*;
44

0 commit comments

Comments
 (0)