Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JsonNode.asInt()


            JsonNode capacity = typeNode.path(JsonConstants.Vehicle.Type.CAPACITY);
            Iterator<JsonNode> capacity_dimension_iterator = capacity.iterator();
            int capacity_index = 0;
            while(capacity_dimension_iterator.hasNext()){
                JsonNode capacity_value = capacity_dimension_iterator.next();
                int capacity_val = capacity_value.asInt();
                typeBuilder.addCapacityDimension(capacity_index,capacity_val);
                capacity_index++;
            }
            VehicleTypeImpl type = typeBuilder.build();
            vehicle_type_map.put(type.getTypeId(),type);
View Full Code Here


    @Test
    public void ints_are_unwrapped() {
        JsonNode node = using(JACKSON_TREE_CONFIGURATION).parse(JSON_DOCUMENT).read("$.int-max-property");
        int unwrapped = using(JACKSON_TREE_CONFIGURATION).parse(JSON_DOCUMENT).read("$.int-max-property", int.class);
        assertThat(unwrapped).isEqualTo(Integer.MAX_VALUE);
        assertThat(unwrapped).isEqualTo(node.asInt());
    }

    @Test
    public void longs_are_unwrapped() {
        JsonNode node = using(JACKSON_TREE_CONFIGURATION).parse(JSON_DOCUMENT).read("$.long-max-property");
View Full Code Here

            if (e.isTextual()) {
                return e.asText();
            } else if (e.isBoolean()) {
                return e.asBoolean();
            } else if (e.isInt()) {
                return e.asInt();
            } else if (e.isLong()) {
                return e.asLong();
            } else if (e.isBigDecimal()) {
                return e.decimalValue();
            } else if (e.isDouble()) {
View Full Code Here

            } else if (valueNode.isObject()) {
                value = jsonNodeToMap(valueNode);
            } else if (valueNode.isBoolean()) {
                value = valueNode.asBoolean();
            } else if (valueNode.isInt()) {
                value = valueNode.asInt();
            } else if (valueNode.isLong()) {
                value = valueNode.asLong();
            } else if (valueNode.isDouble()) {
                value = valueNode.asDouble();
            } else {
View Full Code Here

    private static int intValue(final JsonNode json, final String fieldName) {
        if (json != null) {
            final JsonNode value = json.get(fieldName);

            if (value != null) {
                return value.asInt(-1);
            }
        }
        return -1;
    }
View Full Code Here

            String host = root.path("hostText").asText();
            JsonNode n = root.get("port");
            if (n == null) {
                return HostAndPort.fromString(host);
            }
            return HostAndPort.fromParts(host, n.asInt());
        }
        return super.deserialize(jp, ctxt);
    }

    @Override
View Full Code Here

      degree = node.get(Constants.Education.DEGREE).asText();
    }
    JsonNode childNode;
    if ((childNode = LinkedinAuthUser.traverse(node,
        Constants.Education.START_DATE_YEAR)) != null) {
      startDateYear = childNode.asInt();
    }
    if ((childNode = LinkedinAuthUser.traverse(node,
        Constants.Education.END_DATE_YEAR)) != null) {
      endDateYear = childNode.asInt();
    }
View Full Code Here

        Constants.Education.START_DATE_YEAR)) != null) {
      startDateYear = childNode.asInt();
    }
    if ((childNode = LinkedinAuthUser.traverse(node,
        Constants.Education.END_DATE_YEAR)) != null) {
      endDateYear = childNode.asInt();
    }
    return new EducationInfo(id, schoolName, degree, startDateYear,
        endDateYear);
  }
View Full Code Here

      summary = node.get(Constants.Employment.SUMMARY).asText();
    }
    JsonNode childNode;
    if ((childNode = LinkedinAuthUser.traverse(node,
        Constants.Employment.START_DATE_MONTH)) != null) {
      startDateMonth = childNode.asInt();
    }
    if ((childNode = LinkedinAuthUser.traverse(node,
        Constants.Employment.START_DATE_YEAR)) != null) {
      startDateYear = childNode.asInt();
    }
View Full Code Here

        Constants.Employment.START_DATE_MONTH)) != null) {
      startDateMonth = childNode.asInt();
    }
    if ((childNode = LinkedinAuthUser.traverse(node,
        Constants.Employment.START_DATE_YEAR)) != null) {
      startDateYear = childNode.asInt();
    }
    if ((childNode = LinkedinAuthUser.traverse(node,
        Constants.Employment.END_DATE_MONTH)) != null) {
      endDateMonth = childNode.asInt();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.