List of usage examples for com.fasterxml.jackson.databind.node ArrayNode get
public JsonNode get(String paramString)
From source file:org.gitana.platform.client.log.LogEntryImpl.java
@Override public List<LogThrowable> getLogThrowables() { List<LogThrowable> throwables = new ArrayList<LogThrowable>(); ArrayNode array = getArray(FIELD_THROWABLES); for (int i = 0; i < array.size(); i++) { ObjectNode object = (ObjectNode) array.get(i); throwables.add(new LogThrowable(object)); }// w w w . j a v a2s . c o m return throwables; }
From source file:org.pac4j.oauth.profile.foursquare.FoursquareUserFriends.java
@Override protected void buildFromJson(JsonNode json) { count = json.get("count").asInt(); ArrayNode groupsArray = (ArrayNode) json.get("groups"); for (int i = 0; i < groupsArray.size(); i++) { FoursquareUserFriendGroup group = new FoursquareUserFriendGroup(); group.buildFromJson(groupsArray.get(i)); groups.add(group);//from w w w . ja va 2s . co m } }
From source file:com.marklogic.entityservices.tests.TestEntityTypeSPARQL.java
@Test public void sampleSPARQLQueries() throws JsonGenerationException, JsonMappingException, IOException { String docHasTypeHasPropertyHasDatatype = "PREFIX t: <http://marklogic.com/testing-entity-type#> " + "PREFIX es: <http://marklogic.com/entity-services#> " + "ASK where { t:SchemaCompleteEntityType-0.0.1 a es:Model ; " + " es:definitions ?types ." + "?types es:property ?property ." + "?property es:datatype ?datatype " + "}"; assertTrue(queryMgr.executeAsk(queryMgr.newQueryDefinition(docHasTypeHasPropertyHasDatatype))); String assertTypeHasProperties = "PREFIX t: <http://marklogic.com/testing-entity-type/SchemaCompleteEntityType-0.0.1/> " + "PREFIX es: <http://marklogic.com/entity-services#> " + "SELECT ?version where {" + "t:SchemaCompleteEntityType ?version \"0.0.1\" ." + "}"; JacksonHandle handle = queryMgr.executeSelect(queryMgr.newQueryDefinition(assertTypeHasProperties), new JacksonHandle()); JsonNode results = handle.get();/*from w w w. j a va2 s. c o m*/ // to see on System.out // new ObjectMapper().writerWithDefaultPrettyPrinter().writeValue(System.out, results); ArrayNode bindings = (ArrayNode) results.get("results").get("bindings"); assertEquals(1, bindings.size()); assertEquals("http://marklogic.com/entity-services#version", bindings.get(0).get("version").get("value").asText()); }
From source file:org.apache.solr.kelvin.scorer.EventCollectorScorer.java
@Override public void configure(JsonNode config) throws Exception { if (!config.path("excludes").isMissingNode()) { ArrayNode excludes = ConfigurableLoader.assureArray(config.path("excludes")); for (int i = 0; i < excludes.size(); i++) excludeList.add(excludes.get(i).asText()); } else {// w w w . ja v a 2 s . co m //defaults excludeList.add("org.apache.solr.kelvin.events.ResponseDecodedTestEvent"); excludeList.add("org.apache.solr.kelvin.events.TestCaseTestEvent"); //excludeList.add("org.apache.solr.kelvin.events.MissingFieldTestEvent"); //excludeList.add("org.apache.solr.kelvin.events.MissingResultTestEvent"); } }
From source file:org.pac4j.oauth.profile.foursquare.FoursquareUserFriendGroup.java
@Override protected void buildFromJson(JsonNode json) { count = json.get("count").asInt(); name = json.get("name").asText(); type = json.get("type").asText(); ArrayNode groupsArray = (ArrayNode) json.get("items"); for (int i = 0; i < groupsArray.size(); i++) { FoursquareUserFriend friend = new FoursquareUserFriend(); friend.buildFromJson(groupsArray.get(i)); friends.add(friend);/*from w w w.j a v a 2 s.c o m*/ } }
From source file:io.wcm.caravan.pipeline.impl.JsonPathSelectorTest.java
@Test public void testExtractArraySingleObject() { ArrayNode result = new JsonPathSelector("$.store.bicycle").call(booksJson); assertEquals(1, result.size());/*from www . j a v a 2 s.com*/ assertEquals("red", result.get(0).get("color").asText()); }
From source file:io.wcm.caravan.pipeline.impl.JsonPathSelectorTest.java
@Test public void testExtractArraySingleString() { ArrayNode result = new JsonPathSelector("$.store.bicycle.color").call(booksJson); assertEquals(1, result.size());//from w ww . j av a 2 s .c o m assertEquals("red", result.get(0).asText()); }
From source file:org.gitana.platform.client.transfer.TransferImportJob.java
public List<TransferDependency> getTargets() { List<TransferDependency> targets = new ArrayList<TransferDependency>(); ArrayNode array = getArray(FIELD_TARGETS); for (int i = 0; i < array.size(); i++) { ObjectNode object = (ObjectNode) array.get(i); String typeId = JsonUtil.objectGetString(object, "typeId"); String id = JsonUtil.objectGetString(object, "id"); TransferDependency dependency = new TransferDependency(typeId, id); targets.add(dependency);// w w w. j ava2 s. c o m } return targets; }
From source file:io.wcm.caravan.pipeline.impl.JsonPathSelectorTest.java
@Test public void testExtractArrayMultipleObjects() { ArrayNode result = new JsonPathSelector("$.store.book[*]").call(booksJson); assertEquals(4, result.size());//from w ww .j a v a 2 s . co m assertEquals("Nigel Rees", result.get(0).get("author").asText()); assertEquals("Evelyn Waugh", result.get(1).get("author").asText()); }
From source file:io.wcm.caravan.pipeline.impl.JsonPathSelectorTest.java
@Test public void testExtractArraySingleArray() { // note that this will not give you the array of books directly // to achieve that, use either $.store.book[*] or use the NodeSelector ArrayNode result = new JsonPathSelector("$.store.book").call(booksJson); assertEquals(1, result.size());/*from www .j a va 2s . c om*/ ArrayNode books = (ArrayNode) result.get(0); assertEquals(4, books.size()); assertEquals("Nigel Rees", books.get(0).get("author").asText()); assertEquals("Evelyn Waugh", books.get(1).get("author").asText()); }