log.warn(prefix + "has invalid \"timestamp\": {} (type: {})", timestampNode.asText(), timestampNode.getNodeType().name());
@Override public PathDetail deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode pathDetail = jp.readValueAsTree(); if (pathDetail.size() != 3) throw new JsonParseException(jp, "PathDetail array must have exactly 3 entries but was " + pathDetail.size()); JsonNode from = pathDetail.get(0); JsonNode to = pathDetail.get(1); JsonNode val = pathDetail.get(2); PathDetail pd; if (val.isBoolean()) pd = new PathDetail(val.asBoolean()); else if (val.isLong()) pd = new PathDetail(val.asLong()); else if (val.isInt()) pd = new PathDetail(val.asInt()); else if (val.isDouble()) pd = new PathDetail(val.asDouble()); else if (val.isTextual()) pd = new PathDetail(val.asText()); else throw new JsonParseException(jp, "Unsupported type of PathDetail value " + pathDetail.getNodeType().name()); pd.setFirst(from.asInt()); pd.setLast(to.asInt()); return pd; } }
@Override public Date getDate(int columnIndex) throws SQLException { JsonNode ret = getColumnValue(columnIndex); if (wasNull) { return null; } if (ret instanceof NumericNode) { return new Date(ret.asLong()); } else if (ret instanceof TextNode) { return Date.valueOf(ret.asText()); } else { throw new SQLException("Date converted from " + ret.getNodeType().name() + " not supported"); } }
@Override public Timestamp getTimestamp(int columnIndex) throws SQLException { JsonNode ret = getColumnValue(columnIndex); if (wasNull) { return null; } if (ret instanceof NumericNode) { return new Timestamp(ret.asLong()); } else { throw new SQLException("Date converted from " + ret.getNodeType().name() + " not supported"); } }
@Override public T valueNonNull(JsonNode node) { if (!node.isArray()) { throw new IllegalArgumentException("Node is not an array: " + node.getNodeType().name()); } T container = containerSupplier.get(); ArrayNode array = (ArrayNode) node; array.forEach(child -> container.add(elementConverter.value(child))); return container; } }
@Override public T valueNonNull(JsonNode node) { if (!node.isArray()) { throw new IllegalArgumentException("Node is not an array: " + node.getNodeType().name()); } T container = containerSupplier.get(); ArrayNode array = (ArrayNode) node; array.forEach(child -> container.add(elementConverter.value(child))); return container; } }
@Override protected boolean matchesSafely(JsonNode item, Description mismatchDescription) { if (item.getNodeType() == type) { @SuppressWarnings("unchecked") final A node = (A) item; return matchesNode(node, mismatchDescription); } else { mismatchDescription .appendText("was not ") .appendText(LanguageUtils.addArticle(type.name().toLowerCase())) .appendText(" node, but ") .appendText(LanguageUtils.addArticle(item.getNodeType().name().toLowerCase())) .appendText(" node"); return false; } }
log.warn(prefix + "has invalid \"timestamp\": {} (type: {})", timestampNode.asText(), timestampNode.getNodeType().name());
@Override public PathDetail deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode pathDetail = jp.readValueAsTree(); if (pathDetail.size() != 3) throw new JsonParseException(jp, "PathDetail array must have exactly 3 entries but was " + pathDetail.size()); JsonNode from = pathDetail.get(0); JsonNode to = pathDetail.get(1); JsonNode val = pathDetail.get(2); PathDetail pd; if (val.isBoolean()) pd = new PathDetail(val.asBoolean()); else if (val.isLong()) pd = new PathDetail(val.asLong()); else if (val.isInt()) pd = new PathDetail(val.asInt()); else if (val.isDouble()) pd = new PathDetail(val.asDouble()); else if (val.isTextual()) pd = new PathDetail(val.asText()); else throw new JsonParseException(jp, "Unsupported type of PathDetail value " + pathDetail.getNodeType().name()); pd.setFirst(from.asInt()); pd.setLast(to.asInt()); return pd; } }
data.add(List.of(node.booleanValue(), node.booleanValue())); } else { throw new IllegalStateException("Got unsupported jackson-specific JsonNodeType " + node.getNodeType().name() + ", value: " + node.toString());
private static Object jsonArrayToList(FieldValue arrayFieldValue) { if (!arrayFieldValue.isJsonArray()) { throw new UnsupportedRowJsonException( "Expected JSON array for field '" + arrayFieldValue.name() + "'. " + "Instead got " + arrayFieldValue.jsonNodeType().name()); } return arrayFieldValue .jsonArrayElements() .map( jsonArrayElement -> extractJsonNodeValue( FieldValue.of( arrayFieldValue.name() + "[]", arrayFieldValue.arrayElementType(), jsonArrayElement))) .collect(toList()); }
String nodeType = content.getNodeType().name().toLowerCase(Locale.ROOT);
private static Object extractJsonPrimitiveValue(FieldValue fieldValue) { try { return JSON_VALUE_GETTERS.get(fieldValue.typeName()).extractValue(fieldValue.jsonValue()); } catch (RuntimeException e) { throw new UnsupportedRowJsonException( "Unable to get value from field '" + fieldValue.name() + "'. " + "Schema type '" + fieldValue.typeName() + "'. " + "JSON node type " + fieldValue.jsonNodeType().name(), e); } }
LOG.trace("VALUE IS A " + valueNode.getNodeType().name()); if (valueNode.isNumber()) { if (valueNode.isInt()) {