Search in sources :

Example 36 with JsonNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project KaiZen-OpenAPI-Editor by RepreZen.

the class ObjectTypeDefinition method initProperties.

protected void initProperties(String container, Map<String, TypeDefinition> properties) {
    if (content.has(container) && content.get(container).isObject()) {
        JsonNode node = content.get(container);
        if (JsonReference.isReference(node)) {
            node = schema.resolve(JsonReference.getPointer(node));
        }
        for (Iterator<Entry<String, JsonNode>> it = node.fields(); it.hasNext(); ) {
            Entry<String, JsonNode> e = it.next();
            String property = e.getKey().replaceAll("/", "~1");
            TypeDefinition type = schema.createType(this, container + "/" + property, e.getValue());
            if (type != null) {
                properties.put(e.getKey(), type);
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 37 with JsonNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project KaiZen-OpenAPI-Editor by RepreZen.

the class ErrorProcessor method createMultiple.

private SwaggerError createMultiple(JsonNode error, int indent) {
    final MultipleSwaggerErrorBuilder schemaErrorBuilder = new MultipleSwaggerErrorBuilder().locatedOn(getLine(error, document)).withSeverity(getLevel(error)).indented(indent).basedOnSchema(jsonSchema);
    final JsonNode reports = error.get("reports");
    for (Iterator<Entry<String, JsonNode>> it = reports.fields(); it.hasNext(); ) {
        Entry<String, JsonNode> next = it.next();
        schemaErrorBuilder.withErrorsOnPath(next.getKey(), fromNode(next.getValue(), indent + 1));
    }
    return schemaErrorBuilder.build();
}
Also used : Entry(java.util.Map.Entry) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 38 with JsonNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project KaiZen-OpenAPI-Editor by RepreZen.

the class ErrorProcessor method rewriteEnumError.

protected String rewriteEnumError(JsonNode error) {
    final JsonNode value = error.get("value");
    final JsonNode enums = error.get("enum");
    final String enumString = Joiner.on(", ").join(enums);
    return String.format(Messages.error_notInEnum, value.asText(), enumString);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 39 with JsonNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project EnrichmentMapApp by BaderLab.

the class ColorJsonDeserializer method deserialize.

@Override
public Color deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
    final ObjectCodec oc = jp.getCodec();
    final JsonNode node = oc.readTree(jp);
    return node.isTextual() ? ColorUtil.parseColor(node.asText()) : null;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec)

Example 40 with JsonNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project EnrichmentMapApp by BaderLab.

the class PropertiesJsonDeserializer method deserialize.

@Override
public Map<String, Object> deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
    final Map<String, Object> props = new LinkedHashMap<>();
    final ObjectMapper mapper = (ObjectMapper) jp.getCodec();
    final JsonNode rootNode = mapper.readTree(jp);
    if (rootNode.isObject()) {
        final Iterator<String> fieldNames = rootNode.fieldNames();
        while (fieldNames.hasNext()) {
            final String key = fieldNames.next();
            final JsonNode jn = rootNode.get(key);
            final Object value = readValue(key, jn.toString(), mapper, chart);
            props.put(key, value);
        }
    }
    return props;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)4105 Test (org.junit.Test)1257 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)802 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)544 IOException (java.io.IOException)532 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)384 ArrayList (java.util.ArrayList)315 Test (org.junit.jupiter.api.Test)277 HashMap (java.util.HashMap)249 Map (java.util.Map)201 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)174 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)127 List (java.util.List)122 InputStream (java.io.InputStream)116 KernelTest (com.twosigma.beakerx.KernelTest)114 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)84 Response (javax.ws.rs.core.Response)79 File (java.io.File)78 HttpGet (org.apache.http.client.methods.HttpGet)75 ByteArrayInputStream (java.io.ByteArrayInputStream)70