Skip to content

Commit

Permalink
JSONObject -> Map test.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlasov committed Sep 2, 2019
1 parent 9cc45eb commit 56aa213
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/src/org/nasdanika/core/tests/TestCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -189,4 +190,30 @@ public void testContainerZipping() throws Exception {
assertEquals("Hello", data);
}

@Test
public void testJSONObjectAsMap() {
JSONObject jo = new JSONObject();
jo.put("k1", "String");
jo.put("k2", 33);

JSONObject sjo = new JSONObject();
sjo.put("sk1", "Text");
jo.put("k3", sjo);

JSONArray ja = new JSONArray();
ja.put(1);
ja.put("2");

JSONObject ssjo = new JSONObject();
ssjo.put("ssk1", 88);
ja.put(ssjo);

jo.put("k4", ja);

Map<String, Object> jMap = jo.toMap();
System.out.println(jMap);
System.out.println(jMap.get("k3"));
System.out.println(jMap.get("k4"));
}

}

0 comments on commit 56aa213

Please sign in to comment.