List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
From source file:managers.nodes.LHSManager.java
public Promise<LHS> get(JsonNode properties) { final LHS lhs = new LHS(properties.get("uuid").asText()); Promise<JsonNode> json = toJSON(properties); return json.map(new Function<JsonNode, LHS>() { public LHS apply(JsonNode json) { lhs.json = json;//from w w w . jav a 2s .c o m return lhs; } }); }
From source file:org.echocat.marquardt.common.serialization.PublicKeyDeserializer.java
@Override public PublicKey deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final ObjectCodec oc = jsonParser.getCodec(); final JsonNode node = oc.readTree(jsonParser); return new PublicKeyWithMechanism(node.get(PublicKeySerializer.KEY).binaryValue()).toJavaKey(); }
From source file:com.digitalpebble.stormcrawler.filtering.depth.MaxDepthFilter.java
@Override public void configure(Map stormConf, JsonNode paramNode) { JsonNode node = paramNode.get("maxDepth"); if (node != null && node.isInt()) { maxDepth = node.intValue();//www .ja va2s .c om } else { maxDepth = 0; LOG.warn("maxDepth paramater not found"); } }
From source file:org.eel.kitchen.jsonschema.syntax.PositiveIntegerSyntaxChecker.java
@Override final void checkValue(final Message.Builder msg, final List<Message> messages, final JsonNode schema) { final JsonNode node = schema.get(keyword); msg.addInfo("found", node); if (!node.canConvertToInt()) { msg.setMessage("integer value is too large").addInfo("max", Integer.MAX_VALUE); messages.add(msg.build());//from w ww . j a v a 2s. c o m return; } if (node.intValue() >= 0) return; messages.add(msg.setMessage("value cannot be negative").build()); }
From source file:com.aerospike.cache.HostDeserializer.java
@Override public Host deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = jp.getCodec().readTree(jp); String name = node.get("name").asText(); int port = (Integer) ((IntNode) node.get("port")).numberValue(); return new Host(name, port); }
From source file:com.evrythng.java.wrapper.mapping.ActionJobDeserializer.java
@Override public ActionJob deserialize(final JsonParser jp, final DeserializationContext ctx) throws IOException { ObjectMapper mapper = JSONUtils.OBJECT_MAPPER; JsonNode node = mapper.readTree(jp); JsonNode typeNode = node.get(ActionJob.FIELD_TYPE); if (typeNode == null) { throw new JsonMappingException("Cannot deserialize actions job without type field"); }/*from ww w . ja va2s .com*/ String typeRaw = getFieldValue(typeNode); Class<? extends ActionJob> subtypeClass = classForType(ActionJob.Type.valueOf(typeRaw.toUpperCase())); return mapper.readValue(node.toString(), subtypeClass); }
From source file:com.ikanow.aleph2.analytics.services.DeduplicationService.java
/** The heart of the dedup logic * (everything gets ordered in the correct order except if policy is custom, in which case the ordering is a * bit arbitrary anyway)/* w w w . j a v a 2s . co m*/ * @param policy * @param context * @param timestamp_field * @param new_record * @param old_record * @param key * @param mutable_obj_map * @returns a stream of objects to delete efficiently */ protected static Stream<JsonNode> handleDuplicateRecord(final DocumentSchemaBean config, Optional<Tuple2<IEnrichmentBatchModule, DeduplicationEnrichmentContext>> custom_handler, final String timestamp_field, final LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>> new_records, final List<JsonNode> old_records, final JsonNode key, final Map<JsonNode, LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>>> mutable_obj_map) { return Patterns.match(config.deduplication_policy()).<Stream<JsonNode>>andReturn() .when(p -> p == DeduplicationPolicy.leave, __ -> { mutable_obj_map.remove(key); //(drop new record) return Stream.empty(); }).when(p -> p == DeduplicationPolicy.update, __ -> { final Tuple3<Long, IBatchRecord, ObjectNode> last_record = new_records.peekLast(); final JsonNode old_record = old_records.stream().findFirst().get(); if (newRecordUpdatesOld(timestamp_field, last_record._2().getJson(), old_record)) { last_record._3().set(AnnotationBean._ID, old_record.get(AnnotationBean._ID)); return config.delete_unhandled_duplicates() ? deleteOtherDuplicates(old_records.stream()) : Stream.empty(); } else { mutable_obj_map.remove(key); //(drop new record) return Stream.empty(); } }).when(p -> p == DeduplicationPolicy.overwrite, __ -> { final Tuple3<Long, IBatchRecord, ObjectNode> last_record = new_records.peekLast(); // Just update the new record's "_id" field final JsonNode old_record = old_records.stream().findFirst().get(); last_record._3().set(AnnotationBean._ID, old_record.get(AnnotationBean._ID)); return config.delete_unhandled_duplicates() ? deleteOtherDuplicates(old_records.stream()) : Stream.empty(); }).when(p -> p == DeduplicationPolicy.custom_update, __ -> { final Tuple3<Long, IBatchRecord, ObjectNode> last_record = new_records.peekLast(); final JsonNode old_record = old_records.stream().findFirst().get(); if (newRecordUpdatesOld(timestamp_field, last_record._2().getJson(), old_record)) { mutable_obj_map.remove(key); // (since the "final step" logic is responsible for calling the update code) return handleCustomDeduplication(custom_handler, new_records, old_records, key); } else { mutable_obj_map.remove(key); //(drop new record) return Stream.empty(); } }).otherwise(__ -> { mutable_obj_map.remove(key); // (since the "final step" logic is responsible for calling the update code) return handleCustomDeduplication(custom_handler, new_records, old_records, key); }); }
From source file:net.mostlyharmless.jghservice.connector.jira.GetProjectKeys.java
@Override public List<String> processResponse(String jsonResponse) throws IOException { List<String> list = new LinkedList<>(); ArrayNode jArray = (ArrayNode) new ObjectMapper().readTree(jsonResponse); for (JsonNode node : jArray) { list.add(node.get("key").textValue()); }/*from w w w. ja v a2 s. c o m*/ return list; }
From source file:com.evrythng.java.wrapper.mapping.TaskOnBatchDeserializer.java
@Override public TaskOnBatch 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 on batch without type field"); }//from ww w . ja v a 2 s. c o m String typeRaw = getFieldValue(typeNode); Class<? extends TaskOnBatch> subtypeClass = classForType(TaskOnBatch.Type.valueOf(typeRaw.toUpperCase())); return mapper.readValue(node.toString(), subtypeClass); }
From source file:org.thingsplode.synapse.serializers.jackson.adapters.MediaTypeDeserializer.java
@Override public MediaType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = p.readValueAsTree(); JsonNode mTypeNode = node.get("media_type"); if (mTypeNode == null) { mTypeNode = node.get("content_type"); }/*from w ww. j a va2s .c o m*/ if (mTypeNode == null || Util.isEmpty(mTypeNode.asText())) { return null; } else { return new MediaType(mTypeNode.asText()); } }