List of usage examples for com.fasterxml.jackson.databind JsonNode asText
public abstract String asText();
From source file:com.activiti.service.activiti.EndpointUserProfileService.java
public String getEndpointUserTenantId(String contextRoot, String restRoot, String serverAddress, Integer port, String userName, String password) { JsonNode jsonNode = getEndpointUserProfile(contextRoot, restRoot, serverAddress, port, userName, password); if (jsonNode.has("tenantId") && jsonNode.get("tenantId").isNull() == false) { JsonNode tenantIdNode = jsonNode.get("tenantId"); return tenantIdNode.asText(); }/*from w ww . j a v a 2 s . c om*/ return null; }
From source file:org.flowable.admin.service.engine.EndpointUserProfileService.java
public String getEndpointUserTenantId(String contextRoot, String restRoot, String serverAddress, Integer port, String userName, String password) { JsonNode jsonNode = getEndpointUserProfile(contextRoot, restRoot, serverAddress, port, userName, password); if (jsonNode.has("tenantId") && !jsonNode.get("tenantId").isNull()) { JsonNode tenantIdNode = jsonNode.get("tenantId"); return tenantIdNode.asText(); }/*from www . j a v a2 s .c om*/ return null; }
From source file:com.btmatthews.atlas.core.domain.jsr310.LocalDateTimeDeserializer.java
@Override public LocalDateTime deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { final ObjectCodec codec = parser.getCodec(); final JsonNode node = codec.readTree(parser); return LocalDateTime.parse(node.asText(), DATE_TIME_FORMATTER); }
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:org.openmhealth.schema.pojos.serialize.BloodSpecimenTypeDeserializer.java
@Override public BloodSpecimenType deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return BloodSpecimenType.valueForLabel(node.asText()); }
From source file:org.comicwiki.serializers.YearDeserializer.java
@Override public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = (ObjectMapper) p.getCodec(); JsonNode valueNode = mapper.readTree(p); String dateText = valueNode.asText(); try {// www . j a va 2s . c o m Date time = new SimpleDateFormat("yyyy").parse(dateText); Calendar calendar = Calendar.getInstance(); calendar.setTime(time); calendar.set(Calendar.ERA, (dateText.charAt(0) == '+') ? GregorianCalendar.AD : GregorianCalendar.BC); return calendar.getTime(); } catch (ParseException e) { throw new IOException(e); } }
From source file:org.deeplearning4j.nn.conf.deserializers.IterationListenerDeSerializer.java
@Override public IterationListener deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode node = jp.getCodec().readTree(jp); String val = node.asText(); String[] split = val.split("\t"); if (split.length >= 2) { try {/*from w w w. ja v a 2 s.c om*/ Class<? extends IterationListener> clazz2 = (Class<? extends IterationListener>) Class .forName(split[0]); IterationListener ret = clazz2.newInstance(); Properties props = new Properties(); props.load(new StringReader(split[1])); Dl4jReflection.setProperties(ret, props); return ret; } catch (Exception e) { e.printStackTrace(); } } return null; }
From source file:org.deeplearning4j.nn.conf.deserializers.PreProcessorDeSerializer.java
@Override public OutputPreProcessor deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode node = jp.getCodec().readTree(jp); String val = node.asText(); String[] split = val.split("\t"); if (split.length >= 2) { try {// ww w .j a v a2s.c o m Class<? extends OutputPreProcessor> clazz2 = (Class<? extends OutputPreProcessor>) Class .forName(split[0]); OutputPreProcessor ret = clazz2.newInstance(); Properties props = new Properties(); props.load(new StringReader(split[1])); Dl4jReflection.setProperties(ret, props); return ret; } catch (Exception e) { e.printStackTrace(); } } return null; }
From source file:org.openmhealth.schema.pojos.serialize.HeartRateUnitDeserializer.java
@Override public HeartRateUnitValue.Unit deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return HeartRateUnitValue.Unit.valueForLabel(node.asText()); }
From source file:com.msopentech.odatajclient.engine.data.json.DOMTreeUtils.java
/** * Recursively builds DOM content out of JSON subtree rooted at given node. * * @param document root of the DOM document being built * @param parent parent of the nodes being generated during this step * @param node JSON node to be used as source for DOM elements *///from ww w . j a v a 2 s . c o m public static void buildSubtree(final Element parent, final JsonNode node) { final Iterator<String> fieldNameItor = node.fieldNames(); final Iterator<JsonNode> nodeItor = node.elements(); while (nodeItor.hasNext()) { final JsonNode child = nodeItor.next(); final String name = fieldNameItor.hasNext() ? fieldNameItor.next() : ""; // no name? array item if (name.isEmpty()) { final Element element = parent.getOwnerDocument().createElementNS(ODataConstants.NS_DATASERVICES, ODataConstants.PREFIX_DATASERVICES + ODataConstants.ELEM_ELEMENT); parent.appendChild(element); if (child.isValueNode()) { if (child.isNull()) { element.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_NULL, Boolean.toString(true)); } else { element.appendChild(parent.getOwnerDocument().createTextNode(child.asText())); } } if (child.isContainerNode()) { buildSubtree(element, child); } } else if (!name.contains("@") && !ODataConstants.JSON_TYPE.equals(name)) { final Element property = parent.getOwnerDocument().createElementNS(ODataConstants.NS_DATASERVICES, ODataConstants.PREFIX_DATASERVICES + name); parent.appendChild(property); boolean typeSet = false; if (node.hasNonNull(name + "@" + ODataConstants.JSON_TYPE)) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, node.get(name + "@" + ODataConstants.JSON_TYPE).textValue()); typeSet = true; } if (child.isNull()) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_NULL, Boolean.toString(true)); } else if (child.isValueNode()) { if (!typeSet) { if (child.isInt()) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, EdmSimpleType.Int32.toString()); } if (child.isLong()) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, EdmSimpleType.Int64.toString()); } if (child.isBigDecimal()) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, EdmSimpleType.Decimal.toString()); } if (child.isDouble()) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, EdmSimpleType.Double.toString()); } if (child.isBoolean()) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, EdmSimpleType.Boolean.toString()); } if (child.isTextual()) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, EdmSimpleType.String.toString()); } } property.appendChild(parent.getOwnerDocument().createTextNode(child.asText())); } else if (child.isContainerNode()) { if (!typeSet && child.hasNonNull(ODataConstants.JSON_TYPE)) { property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, child.get(ODataConstants.JSON_TYPE).textValue()); } final String type = property.getAttribute(ODataConstants.ATTR_M_TYPE); if (StringUtils.isNotBlank(type) && EdmSimpleType.isGeospatial(type)) { if (EdmSimpleType.Geography.toString().equals(type) || EdmSimpleType.Geometry.toString().equals(type)) { final String geoType = child.get(ODataConstants.ATTR_TYPE).textValue(); property.setAttributeNS(ODataConstants.NS_METADATA, ODataConstants.ATTR_M_TYPE, geoType.startsWith("Geo") ? EdmSimpleType.namespace() + "." + geoType : type + geoType); } if (child.has(ODataConstants.JSON_COORDINATES) || child.has(ODataConstants.JSON_GEOMETRIES)) { GeospatialJSONHandler.deserialize(child, property, property.getAttribute(ODataConstants.ATTR_M_TYPE)); } } else { buildSubtree(property, child); } } } } }