Java Code Examples for com.fasterxml.jackson.databind.JsonNode#isDouble()

The following examples show how to use com.fasterxml.jackson.databind.JsonNode#isDouble() . 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: TestVariableResolver.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * @see org.mvel2.integration.VariableResolver#getValue()
 */
@Override
public Object getValue() {
    JsonNode varNode = node.get(fieldName);
    if (varNode.isObject()) {
        return varNode;
    } else if (varNode.isArray()) {
        List<Object> rval = new ArrayList<>();
        for (int idx = 0; idx < varNode.size(); idx++) {
            JsonNode idxNode = varNode.get(idx);
            rval.add(idxNode);
        }
        return rval;
    } else if (varNode.isNull()) {
        return null;
    } else if (varNode.isBoolean()) {
        return varNode.asBoolean();
    } else if (varNode.isTextual()) {
        return varNode.asText();
    } else if (varNode.isInt()) {
        return varNode.asInt();
    } else if (varNode.isDouble()) {
        return varNode.asDouble();
    }
    return varNode;
}
 
Example 2
Source File: ThresholdMixinPerfTest.java    From json-schema-validator with Apache License 2.0 6 votes vote down vote up
@Override
public boolean crossesThreshold(JsonNode node) {
    if (maximumDouble.isDouble() && maximumDouble.doubleValue() == Double.POSITIVE_INFINITY) {
        return false;
    }
    if (maximumDouble.isDouble() && maximumDouble.doubleValue() == Double.NEGATIVE_INFINITY) {
        return true;
    }
    if (node.isDouble() && node.doubleValue() == Double.NEGATIVE_INFINITY) {
        return false;
    }
    if (node.isDouble() && node.doubleValue() == Double.POSITIVE_INFINITY) {
        return true;
    }
    final BigDecimal max = new BigDecimal(maximumText);
    BigDecimal value = new BigDecimal(node.asText());
    int compare = value.compareTo(max);
    return compare > 0 || (excludeEqual && compare == 0);
}
 
Example 3
Source File: VariableContainsExpressionFunction.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static boolean arrayNodeContains(ArrayNode arrayNode, Object value) {
    Iterator<JsonNode> iterator = arrayNode.iterator();
    while (iterator.hasNext()) {
        JsonNode jsonNode = iterator.next();
        if (value == null && jsonNode.isNull()) {
            return true;
        } else if (value != null) {
            if (value instanceof String && jsonNode.isTextual() && StringUtils.equals(jsonNode.asText(), (String) value)) {
                return true;
            } else if (value instanceof Number && jsonNode.isLong() && jsonNode.longValue() == ((Number) value).longValue()) {
                return true;
            } else if (value instanceof Number && jsonNode.isDouble() && jsonNode.doubleValue() == ((Number) value).doubleValue()) {
                return true;
            } else if (value instanceof Number && jsonNode.isInt() && jsonNode.intValue() == ((Number) value).intValue()) {
                return true;
            } else if (value instanceof Boolean && jsonNode.isBoolean() && jsonNode.booleanValue() == ((Boolean) value).booleanValue()) {
                return true;
            }
        }
    }   
    return false;
}
 
Example 4
Source File: ThresholdMixinPerfTest.java    From json-schema-validator with Apache License 2.0 6 votes vote down vote up
@Override
public boolean crossesThreshold(JsonNode node) {
    if (maximumDecimal.isDouble() && maximumDecimal.doubleValue() == Double.POSITIVE_INFINITY) {
        return false;
    }
    if (maximumDecimal.isDouble() && maximumDecimal.doubleValue() == Double.NEGATIVE_INFINITY) {
        return true;
    }
    if (node.isDouble() && node.doubleValue() == Double.NEGATIVE_INFINITY) {
        return false;
    }
    if (node.isDouble() && node.doubleValue() == Double.POSITIVE_INFINITY) {
        return true;
    }
    final BigDecimal max = new BigDecimal(maximumText);
    BigDecimal value = new BigDecimal(node.asText());
    int compare = value.compareTo(max);
    return compare > 0 || (excludeEqual && compare == 0);
}
 
Example 5
Source File: JSONReader.java    From bigquery-etl-dataflow-sample with Apache License 2.0 6 votes vote down vote up
/**
 * This method attempts to transform the json node into an object with a known type.
 *
 * @return an Object with the apparent type from JSON (number types are given their wide equivalent (Long for
 * ints, Double for float)
 */
private static Object nodeValueToObject(JsonNode node) { //No child objects or arrays in this flat data just text/number
  switch (node.getNodeType()) {
    case NUMBER:
      if (node.isFloat() || node.isDouble()) {
        return new Double(node.doubleValue());
      } else {
        //For simplicity let all integers be Long.
        return new Long(node.asLong());
      }
    case STRING:
      return node.asText();
    case BOOLEAN:
      return node.asBoolean();
    case NULL:
      return null;
    default:
      logger.warn("Unknown node type:" + node.getNodeType());
      return null;
  }
}
 
Example 6
Source File: JsonUtils.java    From search-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
public static String toString(JsonNode node) {
    if (node == null || node.isNull()) {
        return null;
    }
    if (node.isValueNode()) {
        if (node.isBoolean()) {
            return String.valueOf(node.asBoolean());
        } else if (node.isBigInteger()) {
            return String.valueOf(node.bigIntegerValue());
        } else if (node.isDouble()) {
            return String.valueOf(node.asDouble());
        } else if (node.isInt()) {
            return String.valueOf(node.intValue());
        } else if (node.isLong()) {
            return String.valueOf(node.asLong());
        } else if (node.isShort()) {
            return String.valueOf(node.shortValue());
        } else {
            return node.asText();
        }
    }
    return node.toString();
}
 
Example 7
Source File: MahutaCustomRepositoryImpl.java    From Mahuta with Apache License 2.0 6 votes vote down vote up
/**
 * Deserialize a JSONNode to a primitive object
 *
 * @param node JSON node
 * @return primitive object
 */
public static Object deserialize(JsonNode node) {

    if (node == null || node.isMissingNode() || node.isNull()) {
        return ""; // Because toMap doesn't accept null value ...
    } else if (node.isBoolean()) {
        return node.asBoolean();
    } else if (node.isLong()) {
        return node.asLong();
    } else if (node.isInt()) {
        return node.asInt();
    } else if (node.isDouble()) {
        return node.asDouble();
    } else if (node.isArray()) {
        return StreamSupport
                .stream(Spliterators.spliteratorUnknownSize(node.elements(), Spliterator.ORDERED), false)
                .map(MahutaCustomRepositoryImpl::deserialize).collect(Collectors.toList());
    } else {
        return node.asText();
    }
}
 
Example 8
Source File: JsonQueryParser.java    From searchbox-core with Apache License 2.0 6 votes vote down vote up
private Object getFieldValue(JsonNode fieldValue){
	Object val;
	
	if(fieldValue.isTextual())
		val = fieldValue.asText();
	else if(fieldValue.isInt())
		val = fieldValue.asInt();
	else if(fieldValue.isDouble())
		val = fieldValue.asDouble();
	else if(fieldValue.isBoolean())
		val = fieldValue.asBoolean();
	else
		val = null;
	
	return val;
}
 
Example 9
Source File: WorkflowParser.java    From cwlexec with Apache License 2.0 6 votes vote down vote up
private static Object toDefaultValue(String descTop,
        String id,
        JsonNode defaultNode) throws CWLException {
    Object value = null;
    if (defaultNode != null) {
        if (defaultNode.isTextual()) {
            value = defaultNode.asText();
        } else if (defaultNode.isInt()) {
            value = Integer.valueOf(defaultNode.asInt());
        } else if (defaultNode.isLong()) {
            value = Long.valueOf(defaultNode.asLong());
        } else if (defaultNode.isFloat()) {
            value = Float.valueOf(defaultNode.floatValue());
        } else if (defaultNode.isDouble()) {
            value = Double.valueOf(defaultNode.asDouble());
        } else if (defaultNode.isBoolean()) {
            value = Boolean.valueOf(defaultNode.asBoolean());
        } else if (defaultNode.isArray()) {
            value = toDefaultArrayValue(descTop, id, defaultNode);
        } else if (defaultNode.isObject()) {
            value = toDefaultObjectValue(descTop, id, defaultNode);
        }
    }
    return value;
}
 
Example 10
Source File: JsonUtils.java    From search-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
public static Object parserValue(JsonNode node) {
    if (node == null || node.isNull()) {
        return null;
    }
    if (node.isArray()) {
        return parserArrayNode((ArrayNode) node);
    } else if (node.isObject()) {
        return parserMap((ObjectNode) node);
    } else {
        if (node.isBigDecimal() || node.isBigInteger() || node.isLong()) {
            return node.asLong();
        } else if (node.isFloat() || node.isDouble()) {
            return node.asDouble();
        } else if (node.isInt() || node.isNumber() || node.isShort()) {
            return node.asInt();
        } else if (node.isBoolean()) {
            return node.asBoolean();
        } else if (node.isTextual()) {
            return node.asText();
        } else {// 其他类型
            return node.textValue();
        }
    }
}
 
Example 11
Source File: JsonNodeELResolver.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * If the base object is a map, returns the value associated with the given key, as specified by
 * the property argument. If the key was not found, null is returned. If the base is a Map, the
 * propertyResolved property of the ELContext object must be set to true by this resolver,
 * before returning. If this property is not true after this method is called, the caller should
 * ignore the return value. Just as in java.util.Map.get(Object), just because null is returned
 * doesn't mean there is no mapping for the key; it's also possible that the Map explicitly maps
 * the key to null.
 * 
 * @param context
 *            The context of this evaluation.
 * @param base
 *            The map to analyze. Only bases of type Map are handled by this resolver.
 * @param property
 *            The key to return the acceptable type for. Ignored by this resolver.
 * @return If the propertyResolved property of ELContext was set to true, then the value
 *         associated with the given key or null if the key was not found. Otherwise, undefined.
 * @throws ClassCastException
 *             if the key is of an inappropriate type for this map (optionally thrown by the
 *             underlying Map).
 * @throws NullPointerException
 *             if context is null, or if the key is null and this map does not permit null keys
 *             (the latter is optionally thrown by the underlying Map).
 * @throws ELException
 *             if an exception was thrown while performing the property or variable resolution.
 *             The thrown exception must be included as the cause property of this exception, if
 *             available.
 */
@Override
public Object getValue(ELContext context, Object base, Object property) {
  if (context == null) {
    throw new NullPointerException("context is null");
  }
  Object result = null;
  if (isResolvable(base)) {
    JsonNode resultNode = ((JsonNode) base).get(property.toString());
    if (resultNode != null && resultNode.isValueNode()) {
      if (resultNode.isBoolean()) {
        result = resultNode.asBoolean();
      } else if (resultNode.isLong()) {
        result = resultNode.asLong();
      } else if (resultNode.isBigDecimal() || resultNode.isDouble()) {
        result = resultNode.asDouble();
      } else if (resultNode.isTextual()) {
        result = resultNode.asText();
      } else {
        result = resultNode.toString();
      }
      
    } else {
      result = resultNode;
    }
    context.setPropertyResolved(true);
  }
  return result;
}
 
Example 12
Source File: BaseParser.java    From cwlexec with Apache License 2.0 5 votes vote down vote up
protected static Float processFloatField(String key, JsonNode floatNode) throws CWLException {
    Float floatVal = null;
    if (floatNode != null) {
        if (floatNode.isDouble()) {
            floatVal = Float.valueOf(floatNode.floatValue());
        } else {
            throw new CWLException(ResourceLoader.getMessage(CWL_PARSER_INVALID_TYPE, key, "float"), 251);
        }
    }
    return floatVal;
}
 
Example 13
Source File: AbstractGetFormInstanceModelCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void fillVariablesWithFormValues(Map<String, JsonNode> submittedFormFieldMap, List<FormField> allFields) {
    for (FormField field : allFields) {

        JsonNode fieldValueNode = submittedFormFieldMap.get(field.getId());
        
        if (fieldValueNode == null || fieldValueNode.isNull()) {
            continue;
        }
        
        String fieldType = field.getType();
        String fieldValue = fieldValueNode.asText();

        if (FormFieldTypes.DATE.equals(fieldType)) {
            try {
                if (StringUtils.isNotEmpty(fieldValue)) {
                    LocalDate dateValue = LocalDate.parse(fieldValue);
                    variables.put(field.getId(), dateValue.toString("d-M-yyyy"));
                }
            } catch (Exception e) {
                LOGGER.error("Error parsing form date value for process instance {} and task {} with value {}", processInstanceId, taskId, fieldValue, e);
            }
            
        } else if (fieldValueNode.isBoolean()) {
            variables.put(field.getId(), fieldValueNode.asBoolean());
            
        } else if (fieldValueNode.isLong()) {
            variables.put(field.getId(), fieldValueNode.asLong());
            
        } else if (fieldValueNode.isDouble()) {
            variables.put(field.getId(), fieldValueNode.asDouble());

        } else {
            variables.put(field.getId(), fieldValue);
        }
    }
}
 
Example 14
Source File: JsonNodeELResolver.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * If the base object is a map, returns the value associated with the given key, as specified by the property argument. If the key was not found, null is returned. If the base is a Map, the
 * propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true after this method is called, the caller should ignore the
 * return value. Just as in java.util.Map.get(Object), just because null is returned doesn't mean there is no mapping for the key; it's also possible that the Map explicitly maps the key to null.
 * 
 * @param context
 *            The context of this evaluation.
 * @param base
 *            The map to analyze. Only bases of type Map are handled by this resolver.
 * @param property
 *            The key to return the acceptable type for. Ignored by this resolver.
 * @return If the propertyResolved property of ELContext was set to true, then the value associated with the given key or null if the key was not found. Otherwise, undefined.
 * @throws ClassCastException
 *             if the key is of an inappropriate type for this map (optionally thrown by the underlying Map).
 * @throws NullPointerException
 *             if context is null, or if the key is null and this map does not permit null keys (the latter is optionally thrown by the underlying Map).
 * @throws ELException
 *             if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
 */
@Override
public Object getValue(ELContext context, Object base, Object property) {
    if (context == null) {
        throw new NullPointerException("context is null");
    }
    Object result = null;
    if (isResolvable(base)) {
        JsonNode resultNode = getResultNode((JsonNode) base, property, context);
        if (resultNode != null && resultNode.isValueNode()) {
            if (resultNode.isBoolean()) {
                result = resultNode.asBoolean();
            } else if (resultNode.isShort() || resultNode.isInt()) {
                result = resultNode.asInt();
            } else if (resultNode.isLong()) {
                result = resultNode.asLong();
            } else if (resultNode.isBigDecimal() || resultNode.isDouble() || resultNode.isFloat()) {
                result = resultNode.asDouble();
            } else if (resultNode.isTextual()) {
                result = resultNode.asText();
            } else if (resultNode.isNull()) {
                result = null;
            } else {
                result = resultNode.toString();
            }

        } else {
            result = resultNode;
        }
        context.setPropertyResolved(true);
    }
    return result;
}
 
Example 15
Source File: PrimitiveTypeProvider.java    From cineast with MIT License 5 votes vote down vote up
public static PrimitiveTypeProvider fromJSON(JsonNode json) {
  if (json == null) {
    return NothingProvider.INSTANCE;
  }

  if (json.isTextual()) {
    return new StringTypeProvider(json.asText());
  }

  if (json.isInt()) {
    return new IntTypeProvider(json.asInt());
  }

  if (json.isLong()) {
    return new LongTypeProvider(json.asLong());
  }

  if (json.isFloat()) {
    return new FloatTypeProvider(json.floatValue());
  }

  if (json.isDouble()) {
    return new DoubleTypeProvider(json.doubleValue());
  }

  if (json.isBoolean()) {
    return new BooleanTypeProvider(json.asBoolean());
  }

  // TODO are arrays relevant here?
  return NothingProvider.INSTANCE;
}
 
Example 16
Source File: JSONConfigParser.java    From walkmod-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Map<String, Object> getParams(JsonNode next) {
	if (next.has("params")) {
		Iterator<Entry<String, JsonNode>> it2 = next.get("params").fields();
		Map<String, Object> params = new HashMap<String, Object>();
		while (it2.hasNext()) {
			Entry<String, JsonNode> param = it2.next();
			JsonNode value = param.getValue();
			if (value.isTextual()) {
				params.put(param.getKey(), value.asText());
			} else if (value.isInt()) {
				params.put(param.getKey(), value.asInt());
			} else if (value.isBoolean()) {
				params.put(param.getKey(), value.asBoolean());
			} else if (value.isDouble() || value.isFloat() || value.isBigDecimal()) {
				params.put(param.getKey(), value.asDouble());
			} else if (value.isLong() || value.isBigInteger()) {
				params.put(param.getKey(), value.asLong());
			} else {
				params.put(param.getKey(), value);
			}
			params.put(param.getKey(), param.getValue().asText());
		}
		return params;

	}
	return null;
}
 
Example 17
Source File: GetFormModelWithVariablesCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void fillVariablesWithFormInstanceValues(Map<String, JsonNode> formInstanceFieldMap, List<FormField> allFields, String formInstanceId) {
    for (FormField field : allFields) {

        JsonNode fieldValueNode = formInstanceFieldMap.get(field.getId());

        if (fieldValueNode == null || fieldValueNode.isNull()) {
            continue;
        }

        String fieldType = field.getType();
        String fieldValue = fieldValueNode.asText();

        if (FormFieldTypes.DATE.equals(fieldType)) {
            try {
                if (StringUtils.isNotEmpty(fieldValue)) {
                    LocalDate dateValue = LocalDate.parse(fieldValue);
                    variables.put(field.getId(), dateValue.toString("yyyy-M-d"));
                }
                
            } catch (Exception e) {
                LOGGER.error("Error parsing form date value for form instance {} with value {}", formInstanceId, fieldValue, e);
            }
            
        } else if (fieldValueNode.isBoolean()) {
            variables.put(field.getId(), fieldValueNode.asBoolean());
            
        } else if (fieldValueNode.isLong()) {
            variables.put(field.getId(), fieldValueNode.asLong());
            
        } else if (fieldValueNode.isDouble()) {
            variables.put(field.getId(), fieldValueNode.asDouble());

        } else {
            variables.put(field.getId(), fieldValue);
        }
    }
}
 
Example 18
Source File: RestDMLServiceImpl.java    From sql-layer with GNU Affero General Public License v3.0 4 votes vote down vote up
protected void callDefaultProcedure(PrintWriter writer, HttpServletRequest request, String jsonpArgName,
                                    JDBCCallableStatement call, Map<String,List<String>> queryParams, String jsonParams) throws SQLException {
    if (queryParams != null) {
        for (Map.Entry<String,List<String>> entry : queryParams.entrySet()) {
            if (jsonpArgName.equals(entry.getKey()))
                continue;
            if (entry.getValue().size() != 1)
                throw new WrongExpressionArityException(1, entry.getValue().size());
            call.setString(entry.getKey(), entry.getValue().get(0));
        }
    }
    if (jsonParams != null) {
        JsonNode parsed;
        try {
            parsed = jsonParser(jsonParams).readValueAsTree();
        }
        catch (IOException ex) {
            throw new AkibanInternalException("Error reading from string", ex);
        }
        if (parsed.isObject()) {
            Iterator<String> iter = parsed.fieldNames();
            while (iter.hasNext()) {
                String field = iter.next();
                JsonNode value = parsed.get(field);
                if (value.isBigDecimal()) {
                    call.setBigDecimal(field, value.decimalValue());
                }
                else if (value.isBoolean()) {
                    call.setBoolean(field, value.asBoolean());
                }
                else if (value.isDouble()) {
                    call.setDouble(field, value.asDouble());
                }
                else if (value.isInt()) {
                    call.setInt(field, value.asInt());
                }
                else if (value.isLong()) {
                    call.setLong(field, value.asLong());
                }
                else {
                    call.setString(field, value.textValue());
                }
            }
        }
        else {
            throw new InvalidArgumentTypeException("JSON must be object or array");
        }
    }
    boolean results = call.execute();
    AkibanAppender appender = AkibanAppender.of(writer);
    appender.append('{');
    boolean first = true;
    JDBCParameterMetaData md = (JDBCParameterMetaData)call.getParameterMetaData();
    for (int i = 1; i <= md.getParameterCount(); i++) {
        String name;
        switch (md.getParameterMode(i)) {
        case ParameterMetaData.parameterModeOut:
        case ParameterMetaData.parameterModeInOut:
            name = md.getParameterName(i);
            if (name == null)
                name = String.format("arg%d", i);
            if (first)
                first = false;
            else
                appender.append(',');
            appender.append('"');
            Quote.DOUBLE_QUOTE.append(appender, name);
            appender.append("\":");
            call.formatAsJson(i, appender, options);
            break;
        }
    }
    int nresults = 0;
    while(results) {
        beginResultSetArray(appender, first, nresults++);
        first = false;
        collectResults((JDBCResultSet) call.getResultSet(), appender, options);
        endResultSetArray(appender);
        results = call.getMoreResults();
    }
    appender.append('}');
}
 
Example 19
Source File: JsonFileReader.java    From kafka-connect-fs with Apache License 2.0 4 votes vote down vote up
private static Schema extractSchema(JsonNode jsonNode) {
    switch (jsonNode.getNodeType()) {
        case BOOLEAN:
            return Schema.OPTIONAL_BOOLEAN_SCHEMA;
        case NUMBER:
            if (jsonNode.isShort()) {
                return Schema.OPTIONAL_INT8_SCHEMA;
            } else if (jsonNode.isInt()) {
                return Schema.OPTIONAL_INT32_SCHEMA;
            } else if (jsonNode.isLong()) {
                return Schema.OPTIONAL_INT64_SCHEMA;
            } else if (jsonNode.isFloat()) {
                return Schema.OPTIONAL_FLOAT32_SCHEMA;
            } else if (jsonNode.isDouble()) {
                return Schema.OPTIONAL_FLOAT64_SCHEMA;
            } else if (jsonNode.isBigInteger()) {
                return Schema.OPTIONAL_INT64_SCHEMA;
            } else if (jsonNode.isBigDecimal()) {
                return Schema.OPTIONAL_FLOAT64_SCHEMA;
            } else {
                return Schema.OPTIONAL_FLOAT64_SCHEMA;
            }
        case STRING:
            return Schema.OPTIONAL_STRING_SCHEMA;
        case BINARY:
            return Schema.OPTIONAL_BYTES_SCHEMA;
        case ARRAY:
            Iterable<JsonNode> elements = jsonNode::elements;
            Schema arraySchema = StreamSupport.stream(elements.spliterator(), false)
                    .findFirst().map(JsonFileReader::extractSchema)
                    .orElse(SchemaBuilder.struct().build());
            return SchemaBuilder.array(arraySchema).build();
        case OBJECT:
            SchemaBuilder builder = SchemaBuilder.struct();
            jsonNode.fields()
                    .forEachRemaining(field -> builder.field(field.getKey(), extractSchema(field.getValue())));
            return builder.build();
        default:
            return SchemaBuilder.struct().optional().build();
    }
}
 
Example 20
Source File: JsonFileReader.java    From kafka-connect-fs with Apache License 2.0 4 votes vote down vote up
private Object mapValue(Schema schema, JsonNode value) {
    if (value == null) return null;

    switch (value.getNodeType()) {
        case BOOLEAN:
            return value.booleanValue();
        case NUMBER:
            if (value.isShort()) {
                return value.shortValue();
            } else if (value.isInt()) {
                return value.intValue();
            } else if (value.isLong()) {
                return value.longValue();
            } else if (value.isFloat()) {
                return value.floatValue();
            } else if (value.isDouble()) {
                return value.doubleValue();
            } else if (value.isBigInteger()) {
                return value.bigIntegerValue();
            } else {
                return value.numberValue();
            }
        case STRING:
            return value.asText();
        case BINARY:
            try {
                return value.binaryValue();
            } catch (IOException ioe) {
                throw new RuntimeException(ioe);
            }
        case OBJECT:
        case POJO:
            Struct struct = new Struct(schema);
            Iterable<Map.Entry<String, JsonNode>> fields = value::fields;
            StreamSupport.stream(fields.spliterator(), false)
                    .forEach(field -> struct.put(field.getKey(),
                            mapValue(extractSchema(field.getValue()), field.getValue()))
                    );
            return struct;
        case ARRAY:
            Iterable<JsonNode> arrayElements = value::elements;
            return StreamSupport.stream(arrayElements.spliterator(), false)
                    .map(elm -> mapValue(schema, elm))
                    .collect(Collectors.toList());
        case NULL:
        case MISSING:
        default:
            return null;
    }
}