mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-02 11:05:28 -04:00
Added simple test case
This commit is contained in:
parent
e356739a2f
commit
fafaeb7aa6
@ -35,6 +35,8 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@ -903,6 +905,34 @@ public class XMLConfigurationTest {
|
||||
Util.compareActualVsExpectedJsonArrays(jsonArray, expectedJsonArray);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm XMLParserConfiguration functionality
|
||||
*/
|
||||
@Test
|
||||
public void testSimpleForceList() {
|
||||
|
||||
String xmlStr =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||
"<addresses>\n"+
|
||||
" <address>\n"+
|
||||
" <name>Sherlock Holmes</name>\n"+
|
||||
" </address>\n"+
|
||||
"</addresses>";
|
||||
|
||||
String expectedStr = "{\"addresses\":[{\"address\":{\"name\":\"Sherlock Holmes\"}}]}";
|
||||
|
||||
Set<String> forceList = new HashSet<String>();
|
||||
forceList.add("addresses");
|
||||
|
||||
XMLParserConfiguration config =
|
||||
new XMLParserConfiguration()
|
||||
.withForceList(forceList);
|
||||
JSONObject jsonObject = XML.toJSONObject(xmlStr, config);
|
||||
JSONObject expetedJsonObject = new JSONObject(expectedStr);
|
||||
|
||||
Util.compareActualVsExpectedJsonObjects(jsonObject, expetedJsonObject);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user