List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
From source file:com.redhat.smonkey.Optional.java
@Override public JsonNode generate(JsonNodeFactory nodeFactory, JsonNode data, Monkey mon) { double percent = Utils.asDouble(data.get("percent"), 50.0); if (Utils.rndBool((int) percent)) { JsonNode value = data.get("value"); if (value == null) throw new RuntimeException("value expected"); return mon.generateNode(value); } else {// www . j av a2 s . c o m return Monkey.FIELD_DOES_NOT_EXIST; } }
From source file:com.evrythng.java.wrapper.mapping.TaskNotificationWayDeserializer.java
@Override public Task.Notification.Way deserialize(final JsonParser jp, final DeserializationContext ctx) throws IOException { ObjectMapper mapper = JSONUtils.OBJECT_MAPPER; JsonNode node = mapper.readTree(jp); JsonNode typeNode = node.get(TaskOnBatch.FIELD_TYPE); if (typeNode == null) { throw new JsonMappingException("Cannot deserialize task notification way without type field"); }// ww w . ja v a 2s . c o m String typeRaw = getFieldValue(typeNode); Class<? extends Task.Notification.Way> subtypeClass = classForType( Task.Notification.Way.Type.valueOf(typeRaw.toUpperCase())); return mapper.readValue(node.toString(), subtypeClass); }
From source file:com.github.fge.jsonschema.processors.validation.ArraySchemaDigesterTest.java
@DataProvider public Iterator<Object[]> testData() { JsonNode digest;/*from w w w .j a v a2s .c o m*/ final List<Object[]> list = Lists.newArrayList(); for (final JsonNode node : testNode) { digest = node.get("digest"); for (final JsonNode input : node.get("inputs")) list.add(new Object[] { digest, input }); } return list.iterator(); }
From source file:org.lendingclub.mercator.aws.VPCScanner.java
@Override public Optional<String> computeArn(JsonNode n) { String region = n.get(AWSScanner.AWS_REGION_ATTRIBUTE).asText(); return Optional.of(String.format("arn:aws:ec2:%s:%s:vpc/%s", region, n.get(AccountScanner.ACCOUNT_ATTRIBUTE).asText(), n.get("aws_vpcId").asText())); }
From source file:org.pac4j.oauth.profile.foursquare.FoursquareUserFriend.java
@Override protected void buildFromJson(JsonNode json) { id = json.get("id").asText(); firstName = json.get("firstName").asText(); lastName = json.get("lastName").asText(); gender = Converters.genderConverter.convert(json.get("gender").asText()); relationship = json.get("relationship").asText(); photo = json.get("photo").asText(); bio = json.get("bio").asText(); location = json.get("location").asText(); email = json.get("email").asText(); }
From source file:com.btmatthews.atlas.core.dao.mongo.MongoLocalDateTimeDeserializer.java
@Override public LocalDateTime deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { final ObjectCodec codec = parser.getCodec(); final JsonNode node = codec.readTree(parser); final JsonNode dateNode = node.get("$date"); return LocalDateTime.parse(dateNode.asText(), DATE_TIME_FORMATTER); }
From source file:com.github.restdriver.matchers.HasJsonArray.java
@Override public boolean matchesSafely(JsonNode jsonNode) { JsonNode node = jsonNode.get(fieldName); if (node == null) { return false; }/*from ww w . j av a2s.com*/ if (node.isArray()) { return arrayMatcher.matches(node); } else { return false; } }
From source file:org.eel.kitchen.jsonschema.syntax.ArrayChildrenSyntaxChecker.java
@Override final void checkValue(final Message.Builder msg, final List<Message> messages, final JsonNode schema) { final JsonNode node = schema.get(keyword); if (!node.isArray()) return;// w w w .jav a2s . c o m int index = 0; for (final JsonNode value : node) { final NodeType type = NodeType.getNodeType(value); if (!childrenTypes.contains(type)) { msg.setMessage("incorrect type for array element").addInfo("expected", childrenTypes) .addInfo("found", type).addInfo("index", index); messages.add(msg.build()); } index++; } }
From source file:com.evrythng.java.wrapper.mapping.TaskResultDeserializer.java
@Override public TaskOnBatch.BaseTaskResult deserialize(final JsonParser jp, final DeserializationContext ctx) throws IOException { ObjectMapper mapper = JSONUtils.OBJECT_MAPPER; JsonNode node = mapper.readTree(jp); JsonNode typeNode = node.get(TaskOnBatch.FIELD_TYPE); if (typeNode == null) { throw new JsonMappingException("Cannot deserialize task result without type field"); }//from w w w. jav a 2s.co m String typeRaw = getFieldValue(typeNode); Class<? extends TaskOnBatch.BaseTaskResult> subtypeClass = classForType( TaskOnBatch.BaseTaskResult.Type.valueOf(typeRaw.toUpperCase())); return mapper.readValue(node.toString(), subtypeClass); }
From source file:com.evrythng.java.wrapper.mapping.ShortIdTemplateDeserializer.java
@Override public ShortIdTemplate deserialize(final JsonParser jp, final DeserializationContext ctx) throws IOException { ObjectMapper mapper = JSONUtils.OBJECT_MAPPER; JsonNode node = mapper.readTree(jp); JsonNode typeNode = node.get(ShortIdTemplate.FIELD_TYPE); if (typeNode == null) { throw new JsonMappingException("Cannot deserialize task on batch without type field"); }/*from w w w . j a v a 2 s . c o m*/ String typeRaw = getFieldValue(typeNode); Class<? extends ShortIdTemplate> subtypeClass = classForType( ShortIdTemplate.Type.valueOf(typeRaw.toUpperCase())); return mapper.readValue(node.toString(), subtypeClass); }