List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
From source file:org.springframework.social.twitter.api.impl.SimilarPlacesDeserializer.java
@Override public SimilarPlacesResponse deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new TwitterModule()); jp.setCodec(mapper);/*from w ww. j av a 2 s.co m*/ JsonNode node = jp.readValueAs(JsonNode.class); JsonNode resultNode = node.get("result"); String token = resultNode.get("token").textValue(); JsonNode placesNode = resultNode.get("places"); @SuppressWarnings("unchecked") List<Place> places = (List<Place>) mapper.reader(new TypeReference<List<Place>>() { }).readValue(placesNode); return new SimilarPlacesResponse(places, token); }
From source file:com.github.fge.avro.Avro2JsonSchemaProcessorTest.java
@Test public void illegalSchemasAreReportedAsSuch() throws ProcessingException { final JsonTree tree = new SimpleJsonTree(schema); final ValueHolder<JsonTree> input = ValueHolder.hold(tree); final ProcessingReport report = new DevNullProcessingReport(); try {/*from w ww. j av a2 s . c om*/ new Avro2JsonSchemaProcessor().process(report, input); fail("No exception thrown!!"); } catch (IllegalAvroSchemaException e) { final ProcessingMessage message = e.getProcessingMessage(); final JsonNode node = message.asJson(); assertEquals(node.get("exceptionClass").textValue(), SchemaParseException.class.getCanonicalName()); } }
From source file:org.openlmis.fulfillment.util.CustomSortDeserializer.java
@Override public Sort deserialize(JsonParser parser, DeserializationContext context) throws IOException { ArrayNode node = parser.getCodec().readTree(parser); Sort.Order[] orders = new Sort.Order[node.size()]; int index = 0; for (JsonNode obj : node) { orders[index] = new Sort.Order(Sort.Direction.valueOf(obj.get("direction").asText()), obj.get("property").asText()); index++;//from w ww .j ava 2 s. c om } return new Sort(orders); }
From source file:org.springframework.security.jackson2.UserDeserializer.java
private JsonNode readJsonNode(JsonNode jsonNode, String field) { return jsonNode.has(field) ? jsonNode.get(field) : MissingNode.getInstance(); }
From source file:vk.model.VKApiOwner.java
/** * Fills an owner from JsonNode/*from www .ja va 2 s. c o m*/ */ public VKApiOwner parse(JsonNode from) { fields = from; id = from.get("id").asInt(); return this; }
From source file:com.github.fge.jsonschema.processors.validation.ObjectSchemaSelector.java
public ObjectSchemaSelector(final JsonNode digest) { hasAdditional = digest.get("hasAdditional").booleanValue(); List<String> list; list = Lists.newArrayList();/*from w w w .ja va 2 s .c om*/ for (final JsonNode node : digest.get("properties")) list.add(node.textValue()); properties = ImmutableList.copyOf(list); list = Lists.newArrayList(); for (final JsonNode node : digest.get("patternProperties")) list.add(node.textValue()); patternProperties = ImmutableList.copyOf(list); }
From source file:org.eel.kitchen.jsonschema.format.AbstractFormatAttributeTest.java
@DataProvider protected Iterator<Object[]> getData() { final Set<Object[]> set = Sets.newHashSet(); for (final JsonNode node : testData) set.add(new Object[] { node.get("data"), node.get("valid").booleanValue() }); return set.iterator(); }
From source file:com.github.fge.jsonschema.processors.validation.ArraySchemaSelectorTest.java
@DataProvider public Iterator<Object[]> testData() throws ProcessingException, JsonPointerException { final List<Object[]> list = Lists.newArrayList(); JsonNode digest;//from w w w .j av a 2s . c o m int elementIndex; List<JsonPointer> ret; for (final JsonNode node : testNode) { digest = node.get("digest"); elementIndex = node.get("elementIndex").intValue(); ret = Lists.newArrayList(); for (final JsonNode element : node.get("ret")) ret.add(new JsonPointer(element.textValue())); list.add(new Object[] { digest, elementIndex, ret }); } return list.iterator(); }
From source file:com.github.fge.jsonschema.processors.validation.ObjectSchemaSelectorTest.java
@DataProvider public Iterator<Object[]> testData() throws ProcessingException, JsonPointerException { final List<Object[]> list = Lists.newArrayList(); JsonNode digest;/*from w w w .j av a2 s. c om*/ String memberName; List<JsonPointer> ret; for (final JsonNode node : testNode) { digest = node.get("digest"); memberName = node.get("memberName").textValue(); ret = Lists.newArrayList(); for (final JsonNode element : node.get("ret")) ret.add(new JsonPointer(element.textValue())); list.add(new Object[] { digest, memberName, ret }); } return list.iterator(); }