List of usage examples for io.vertx.core.json JsonObject getMap
public Map<String, Object> getMap()
From source file:com.groupon.vertx.memcache.codec.RetrieveCommandResponseCodec.java
License:Apache License
@Override public RetrieveCommandResponse decodeFromWire(int i, Buffer buffer) { JsonObject json = CodecManager.JSON_OBJECT_MESSAGE_CODEC.decodeFromWire(i, buffer); JsendStatus status = JsendStatus.valueOf(json.getString("status")); String message = json.getString("message"); JsonObject jsonData = json.getJsonObject("data"); Map<String, String> data = null; if (jsonData != null) { data = new HashMap<>(); for (Map.Entry<String, Object> entry : jsonData.getMap().entrySet()) { data.put(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null); }/*from w w w . ja va 2s . c o m*/ } return new RetrieveCommandResponse.Builder().setStatus(status).setMessage(message).setData(data).build(); }
From source file:de.elsibay.vertx.ExtendedJsonObjectCodec.java
@Override public ExtendedJsonObject decodeFromWire(int pos, Buffer buffer) { logger.debug("decode from wire"); JsonObject jo = this.jomCodec.decodeFromWire(pos, buffer); return new ExtendedJsonObject(jo.getMap()); }
From source file:de.elsibay.vertx.ExtendedJsonObjectCodec.java
@Override public ExtendedJsonObject transform(ExtendedJsonObject s) { logger.debug("transform"); JsonObject jo = this.jomCodec.transform(s); return new ExtendedJsonObject(jo.getMap()); }
From source file:enmasse.kafka.bridge.converter.JsonMessageConverter.java
License:Apache License
@Override public Message toAmqpMessage(String amqpAddress, ConsumerRecord<String, byte[]> record) { Message message = Proton.message();/*from w w w . j a va2s . com*/ message.setAddress(amqpAddress); // get the root JSON JsonObject json = new JsonObject(new String(record.value())); // get AMQP properties from the JSON JsonObject jsonProperties = json.getJsonObject(JsonMessageConverter.PROPERTIES); if (jsonProperties != null) { for (Entry<String, Object> entry : jsonProperties) { if (entry.getValue() != null) { if (entry.getKey().equals(JsonMessageConverter.MESSAGE_ID)) { message.setMessageId(entry.getValue()); } else if (entry.getKey().equals(JsonMessageConverter.TO)) { message.setAddress(entry.getValue().toString()); } else if (entry.getKey().equals(JsonMessageConverter.SUBJECT)) { message.setSubject(entry.getValue().toString()); } else if (entry.getKey().equals(JsonMessageConverter.REPLY_TO)) { message.setReplyTo(entry.getValue().toString()); } else if (entry.getKey().equals(JsonMessageConverter.CORRELATION_ID)) { message.setCorrelationId(entry.getValue()); } } } } // get AMQP application properties from the JSON JsonObject jsonApplicationProperties = json.getJsonObject(JsonMessageConverter.APPLICATION_PROPERTIES); if (jsonApplicationProperties != null) { Map<Symbol, Object> applicationPropertiesMap = new HashMap<>(); for (Entry<String, Object> entry : jsonApplicationProperties) { applicationPropertiesMap.put(Symbol.valueOf(entry.getKey()), entry.getValue()); } ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap); message.setApplicationProperties(applicationProperties); } // put message annotations about partition, offset and key (if not null) Map<Symbol, Object> messageAnnotationsMap = new HashMap<>(); messageAnnotationsMap.put(Symbol.valueOf(Bridge.AMQP_PARTITION_ANNOTATION), record.partition()); messageAnnotationsMap.put(Symbol.valueOf(Bridge.AMQP_OFFSET_ANNOTATION), record.offset()); if (record.key() != null) messageAnnotationsMap.put(Symbol.valueOf(Bridge.AMQP_KEY_ANNOTATION), record.key()); messageAnnotationsMap.put(Symbol.valueOf(Bridge.AMQP_TOPIC_ANNOTATION), record.topic()); // get AMQP message annotations from the JSON JsonObject jsonMessageAnnotations = json.getJsonObject(JsonMessageConverter.MESSAGE_ANNOTATIONS); if (jsonMessageAnnotations != null) { for (Entry<String, Object> entry : jsonMessageAnnotations) { messageAnnotationsMap.put(Symbol.valueOf(entry.getKey()), entry.getValue()); } } MessageAnnotations messageAnnotations = new MessageAnnotations(messageAnnotationsMap); message.setMessageAnnotations(messageAnnotations); // get the AMQP message body from the JSON JsonObject jsonBody = json.getJsonObject(JsonMessageConverter.BODY); if (jsonBody != null) { // type attribtute for following sectin : AMQP value or raw data/binary String type = jsonBody.getString(JsonMessageConverter.SECTION_TYPE); if (type.equals(JsonMessageConverter.SECTION_AMQP_VALUE_TYPE)) { // section is an AMQP value Object jsonSection = jsonBody.getValue(JsonMessageConverter.SECTION); // encoded as String if (jsonSection instanceof String) { message.setBody(new AmqpValue(jsonSection)); // encoded as an array/List } else if (jsonSection instanceof JsonArray) { JsonArray jsonArray = (JsonArray) jsonSection; message.setBody(new AmqpValue(jsonArray.getList())); // encoded as a Map } else if (jsonSection instanceof JsonObject) { JsonObject jsonObject = (JsonObject) jsonSection; message.setBody(new AmqpValue(jsonObject.getMap())); } } else if (type.equals(JsonMessageConverter.SECTION_DATA_TYPE)) { // section is a raw binary data // get the section from the JSON (it's base64 encoded) byte[] value = jsonBody.getBinary(JsonMessageConverter.SECTION); message.setBody(new Data(new Binary(Base64.getDecoder().decode(value)))); } } return message; }
From source file:io.apiman.gateway.platforms.vertx3.config.VertxEngineConfig.java
License:Apache License
protected Map<String, String> toFlatStringMap(JsonObject jsonObject) { Map<String, String> outMap = new HashMap<>(); for (Entry<String, Object> pair : jsonObject.getMap().entrySet()) { outMap.put(pair.getKey(), pair.getValue().toString()); }//from ww w .j a va2 s . c om return outMap; }
From source file:io.engagingspaces.graphql.proxy.GraphQLSchemaProxy.java
License:Open Source License
/** * Executes a blocking call to the GraphQL query processor and executes the query. * * @param graphqlQuery the graphql query * @param variables the variables to pass to the query * @return the graphql query result/*from w ww.j a va2 s .c o m*/ */ public QueryResult queryBlocking(String graphqlQuery, JsonObject variables) { Objects.requireNonNull(graphqlQuery, "GraphQL query cannot be null"); GraphQL graphQL = new GraphQL(this); ExecutionResult result; if (variables == null) { result = graphQL.execute(graphqlQuery); } else { result = graphQL.execute(graphqlQuery, (Object) null, variables.getMap()); } return SchemaDefinition.convertToQueryResult(result); }
From source file:io.engagingspaces.graphql.schema.SchemaDefinition.java
License:Open Source License
/** * Executes a blocking call to the GraphQL query processor and executes the query. * * @param graphqlQuery the graphql query * @param variables the variables to pass to the query * @return the graphql query result/* w w w. j a v a2 s.c o m*/ */ default QueryResult queryBlocking(String graphqlQuery, JsonObject variables) { Objects.requireNonNull(graphqlQuery, "GraphQL query cannot be null"); GraphQL graphQL = new GraphQL(schema()); ExecutionResult result; if (variables == null) { result = graphQL.execute(graphqlQuery); } else { result = graphQL.execute(graphqlQuery, (Object) null, variables.getMap()); } return convertToQueryResult(result); }
From source file:io.flowly.core.data.Entity.java
License:Open Source License
public Entity(JsonObject entity) { super(entity.getMap()); }
From source file:io.flowly.engine.data.manager.FlowInstanceReadWriteManager.java
License:Open Source License
private void updateFlowObjectProperties(Vertex vertex, FlowInstance instance, String status, boolean saveMetadata) { vertex.property(Schema.P_STATUS, status); if (instance == null) { return;// w w w .j a v a 2 s.co m } if (saveMetadata) { vertex.property(Schema.V_P_META_DATA, instance.getMetadata().encode()); vertex.property(Schema.V_P_INSTANCE_ID, instance.getMetadata().getInstanceId()); } JsonObject data = instance.getData(); if (data != null && data.getMap().size() > 0) { vertex.property(Schema.V_P_DATA, data.encode()); } JsonObject inputData = instance.getInputData(); if (inputData != null && inputData.getMap().size() > 0) { vertex.property(Schema.V_P_INPUT_DATA, inputData.encode()); } JsonObject outputData = instance.getOutputData(); if (outputData != null && outputData.getMap().size() > 0) { vertex.property(Schema.V_P_OUTPUT_DATA, outputData.encode()); } }
From source file:io.github.qrman.guice.WimbledonModule.java
License:Open Source License
private Properties extractToProperties(JsonObject config) { Properties properties = new Properties(); config.getMap().keySet().stream().forEach((String key) -> { properties.setProperty(key, (String) config.getValue(key)); });/*w ww. j av a 2 s .c o m*/ return properties; }