Java Code Examples for com.eclipsesource.json.JsonArray#readFrom()
The following examples show how to use
com.eclipsesource.json.JsonArray#readFrom() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlobalCacheIrDatabase.java From IrScrutinizer with GNU General Public License v3.0 | 5 votes |
private JsonArray getJsonArray(String str) throws IOException { URL url = new URL("http", globalCacheIrDatabaseHost, path + apiKey + "/" + str); if (verbose) System.err.println("Opening " + url.toString() + " using proxy " + proxy); URLConnection urlConnection = url.openConnection(proxy); return JsonArray.readFrom(new InputStreamReader(urlConnection.getInputStream(), Charset.forName("US-ASCII"))); }
Example 2
Source File: BoxBrowseController.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
@Override public ArrayList<String> getRecentSearches(Context context, BoxUser user) { String recentSearchesString = context.getSharedPreferences(RECENT_SEARCHES_KEY + user.getId(), Context.MODE_PRIVATE).getString(RECENT_SEARCHES_KEY, null); ArrayList<String> recentSearches = new ArrayList<String>(); if (recentSearchesString != null) { JsonArray recentSearchesJsonArray = JsonArray.readFrom(recentSearchesString); for (int i = 0; i < recentSearchesJsonArray.size(); i++) { recentSearches.add(recentSearchesJsonArray.get(i).asString()); } } return recentSearches; }
Example 3
Source File: MetadataTest.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Test @Category(UnitTest.class) public void testAdd() { Metadata m = new Metadata().add("/foo", "bar"); JsonArray operations = JsonArray.readFrom(m.getPatch()); Assert.assertEquals(1, operations.size()); JsonObject op = operations.get(0).asObject(); Assert.assertEquals("add", op.get("op").asString()); Assert.assertEquals("/foo", op.get("path").asString()); Assert.assertEquals("bar", op.get("value").asString()); }
Example 4
Source File: MetadataTest.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Test @Category(UnitTest.class) public void testReplace() { Metadata m = new Metadata().replace("/foo", "bar"); JsonArray operations = JsonArray.readFrom(m.getPatch()); Assert.assertEquals(1, operations.size()); JsonObject op = operations.get(0).asObject(); Assert.assertEquals("replace", op.get("op").asString()); Assert.assertEquals("/foo", op.get("path").asString()); Assert.assertEquals("bar", op.get("value").asString()); }
Example 5
Source File: MetadataTest.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Test @Category(UnitTest.class) public void testReplaceWithMultiSelect() { List<String> valueList = new ArrayList<String>(); valueList.add("bar"); valueList.add("qux"); Metadata m = new Metadata().replace("/foo", valueList); JsonArray operations = JsonArray.readFrom(m.getPatch()); Assert.assertEquals(1, operations.size()); JsonObject op = operations.get(0).asObject(); Assert.assertEquals("replace", op.get("op").asString()); Assert.assertEquals("/foo", op.get("path").asString()); Assert.assertEquals("[\"bar\",\"qux\"]", op.get("value").toString()); }
Example 6
Source File: MetadataTest.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Test @Category(UnitTest.class) public void testTest() { Metadata m = new Metadata().test("/foo", "bar"); JsonArray operations = JsonArray.readFrom(m.getPatch()); Assert.assertEquals(1, operations.size()); JsonObject op = operations.get(0).asObject(); Assert.assertEquals("test", op.get("op").asString()); Assert.assertEquals("/foo", op.get("path").asString()); Assert.assertEquals("bar", op.get("value").asString()); }
Example 7
Source File: MetadataTest.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Test @Category(UnitTest.class) public void testMultiSelect() { String expectedList = "[\"public test 1\",\"public test 2\",\"public test 3\"]"; List<String> list = new ArrayList<>(); list.add("public test 1"); list.add("public test 2"); list.add("public test 3"); Metadata m = new Metadata().test("/foo", list); JsonArray operations = JsonArray.readFrom(m.getPatch()); JsonObject op = operations.get(0).asObject(); Assert.assertEquals("test", op.get("op").asString()); Assert.assertEquals("/foo", op.get("path").asString()); Assert.assertEquals(expectedList, op.get("value").toString()); }
Example 8
Source File: MetadataTest.java From box-java-sdk with Apache License 2.0 | 5 votes |
@Test @Category(UnitTest.class) public void testRemove() { Metadata m = new Metadata().remove("/foo"); JsonArray operations = JsonArray.readFrom(m.getPatch()); Assert.assertEquals(1, operations.size()); JsonObject op = operations.get(0).asObject(); Assert.assertEquals("remove", op.get("op").asString()); Assert.assertEquals("/foo", op.get("path").asString()); }
Example 9
Source File: ControlTowerIrDatabase.java From IrScrutinizer with GNU General Public License v3.0 | 4 votes |
private JsonArray getJsonArray(String str) throws IOException { JsonArray arr = JsonArray.readFrom(getReader(str)); return arr; }