List of usage examples for com.fasterxml.jackson.databind JsonNode asText
public abstract String asText();
From source file:alpine.json.TrimmedStringDeserializer.java
@Override public String deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException { final JsonNode node = jsonParser.readValueAsTree(); return StringUtils.trimToNull(node.asText()); }
From source file:com.aol.one.patch.testobj.PatchableMap.java
@Override public void addValue(String key, JsonNode value) { if (key != null && value != null) { this.put(key, value.asText()); }//from w w w. j a v a2 s .c om }
From source file:io.fabric8.che.starter.client.keycloak.KeycloakClient.java
@Override public String getOpenShiftToken(String authHeader) throws JsonProcessingException, IOException { // {"access_token":"token","expires_in":86400,"scope":"user:full","token_type":"Bearer"} String responseBody = getResponseBody(KeycloakEndpoint.GET_OPENSHIFT_TOKEN, authHeader); ObjectMapper mapper = new ObjectMapper(); JsonNode json = mapper.readTree(responseBody); JsonNode accessToken = json.get(ACCESS_TOKEN); return accessToken.asText(); }
From source file:org.openmhealth.schema.pojos.serialize.PositionDuringMeasurementDeserializer.java
@Override public PositionDuringMeasurement deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return PositionDuringMeasurement.valueForLabel(node.asText()); }
From source file:org.openmhealth.schema.pojos.serialize.BloodGlucoseUnitValueDeserializer.java
@Override public BloodGlucoseUnitValue.Unit deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return BloodGlucoseUnitValue.Unit.valueForLabel(node.asText()); }
From source file:com.ikanow.aleph2.analytics.services.DeduplicationService.java
/** Converts a JsonNode to a timestamp if possible * @param in/*from www .j ava2 s . co m*/ * @return */ public static Optional<Long> getTimestampFromJsonNode(final JsonNode in) { if (null == in) { return Optional.empty(); } else if (in.isNumber()) { return Optional.of(in.asLong()); } else if (in.isTextual()) { return Optional.ofNullable( TimeUtils.parseIsoString(in.asText()).validation(fail -> null, success -> success.getTime())); } else { return Optional.empty(); } }
From source file:io.gravitee.definition.jackson.datatype.api.deser.AbstractStdScalarDeserializer.java
protected String readStringValue(JsonNode rootNode, String fieldName, String defaultValue) { JsonNode fieldNode = rootNode.get(fieldName); if (fieldNode != null) { return fieldNode.asText(); }/*from w w w. j a va2 s.c o m*/ return defaultValue; }
From source file:com.mapr.synth.samplers.JoinSampler.java
@Override public JsonNode sample() { JsonNode value = delegate.sample();//from ww w . j av a2s .c o m StringBuilder r = new StringBuilder(); String separator = ""; for (JsonNode component : value) { r.append(separator); r.append(component.asText()); separator = this.separator; } return new TextNode(r.toString()); }
From source file:org.openmhealth.schema.pojos.serialize.TemporalRelationshipToPhysicalActivityDeserializer.java
@Override public TemporalRelationshipToPhysicalActivity deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return TemporalRelationshipToPhysicalActivity.valueForLabel(node.asText()); }
From source file:io.swagger.inflector.processors.JsonExampleDeserializer.java
@Override public Example deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Example output = null;/*from w w w. ja v a 2 s .c om*/ JsonNode node = jp.getCodec().readTree(jp); if (node instanceof ObjectNode) { ObjectExample obj = new ObjectExample(); ObjectNode on = (ObjectNode) node; for (Iterator<Entry<String, JsonNode>> x = on.fields(); x.hasNext();) { Entry<String, JsonNode> i = x.next(); String key = i.getKey(); JsonNode value = i.getValue(); obj.put(key, new StringExample(value.asText())); output = obj; } } else if (node instanceof TextNode) { output = new StringExample(((TextNode) node).asText()); } return output; }