/**
* Test the construction from a simple map.
*/
public void test_newFromMap() {
JSONObject jObject = null;
JSONArray jArr = null;
Exception ex = null;
HashMap map = new HashMap();
map.put("string", "This is a string");
map.put("null", null);
map.put("integer", new Integer(1));
map.put("bool", new Boolean(true));
map.put("strArr", new String[]{"first", "second", "third"});
// Load a JSON object from a map with JSONable values.
try {
jObject = new JSONObject(map);
jArr = (JSONArray)jObject.get("strArr");
} catch (Exception ex1) {
ex = ex1;
ex.printStackTrace();
}
assertTrue(jObject != null);
assertTrue(jObject.length() == 5);
assertTrue("first".equals((String)jArr.get(0)));
assertTrue("second".equals((String)jArr.get(1)));
assertTrue("third".equals((String)jArr.get(2)));
assertTrue(ex == null);