Java Code Examples for com.fasterxml.jackson.databind.JsonNode#asToken()
The following examples show how to use
com.fasterxml.jackson.databind.JsonNode#asToken() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CayenneExpParser.java From agrest with Apache License 2.0 | 6 votes |
private static Object extractValue(JsonNode valueNode) { JsonToken type = valueNode.asToken(); switch (type) { case VALUE_NUMBER_INT: return valueNode.asInt(); case VALUE_NUMBER_FLOAT: return valueNode.asDouble(); case VALUE_TRUE: return Boolean.TRUE; case VALUE_FALSE: return Boolean.FALSE; case VALUE_NULL: return null; case START_ARRAY: return extractArray(valueNode); default: // String parameters may need to be parsed further. Defer parsing // until it is placed in the context of an expression... return valueNode; } }
Example 2
Source File: SenchaFilterParser.java From agrest with Apache License 2.0 | 6 votes |
private static Object extractValue(JsonNode valueNode) { JsonToken type = valueNode.asToken(); // ExtJS converts everything to String except for NULL and booleans. So // follow the same logic here... // (http://docs.sencha.com/extjs/4.1.2/source/Filter.html#Ext-util-Filter) switch (type) { case VALUE_NULL: return null; case VALUE_FALSE: return false; case VALUE_TRUE: return true; case VALUE_NUMBER_INT: return valueNode.asInt(); case VALUE_NUMBER_FLOAT: return valueNode.asDouble(); case START_ARRAY: return extractArray(valueNode); default: return valueNode.asText(); } }
Example 3
Source File: GenericConverter.java From agrest with Apache License 2.0 | 6 votes |
@Override public Object value(JsonNode valueNode) { JsonToken type = valueNode.asToken(); switch (type) { case VALUE_NUMBER_INT: return valueNode.asInt(); case VALUE_NUMBER_FLOAT: return valueNode.asDouble(); case VALUE_TRUE: return Boolean.TRUE; case VALUE_FALSE: return Boolean.FALSE; case VALUE_NULL: return null; default: return valueNode.asText(); } }
Example 4
Source File: JacksonConverterImpl.java From aws-dynamodb-mars-json-demo with Apache License 2.0 | 6 votes |
/** * Gets an DynamoDB representation of a JsonNode. * * @param node * The JSON to convert * @param depth * Current JSON depth * @return DynamoDB representation of the JsonNode * @throws JacksonConverterException * Unknown JsonNode type or JSON is too deep */ private AttributeValue getAttributeValue(final JsonNode node, final int depth) throws JacksonConverterException { assertDepth(depth); switch (node.asToken()) { case VALUE_STRING: return new AttributeValue().withS(node.textValue()); case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: return new AttributeValue().withN(node.numberValue().toString()); case VALUE_TRUE: case VALUE_FALSE: return new AttributeValue().withBOOL(node.booleanValue()); case VALUE_NULL: return new AttributeValue().withNULL(true); case START_OBJECT: return new AttributeValue().withM(jsonObjectToMap(node, depth)); case START_ARRAY: return new AttributeValue().withL(jsonArrayToList(node, depth)); default: throw new JacksonConverterException("Unknown node type: " + node); } }
Example 5
Source File: TreeTraversingParser.java From lams with GNU General Public License v2.0 | 5 votes |
protected JsonNode currentNumericNode() throws JsonParseException { JsonNode n = currentNode(); if (n == null || !n.isNumber()) { JsonToken t = (n == null) ? null : n.asToken(); throw _constructError("Current token ("+t+") not numeric, cannot use numeric value accessors"); } return n; }