Search in sources :

Example 26 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project jsonschema2pojo by joelittlejohn.

the class SchemaMapper method readSchema.

private ObjectNode readSchema(URL schemaUrl) {
    switch(ruleFactory.getGenerationConfig().getSourceType()) {
        case JSONSCHEMA:
            ObjectNode schemaNode = NODE_FACTORY.objectNode();
            schemaNode.put("$ref", schemaUrl.toString());
            return schemaNode;
        case JSON:
            return schemaGenerator.schemaFromExample(schemaUrl);
        default:
            throw new IllegalArgumentException("Unrecognised source type: " + ruleFactory.getGenerationConfig().getSourceType());
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 27 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project jsonschema2pojo by joelittlejohn.

the class SchemaGenerator method simpleTypeSchema.

private ObjectNode simpleTypeSchema(JsonNode exampleValue) {
    try {
        Object valueAsJavaType = OBJECT_MAPPER.treeToValue(exampleValue, Object.class);
        SchemaAware valueSerializer = getValueSerializer(valueAsJavaType);
        return (ObjectNode) valueSerializer.getSchema(OBJECT_MAPPER.getSerializerProvider(), null);
    } catch (JsonMappingException e) {
        throw new GenerationException("Unable to generate a schema for this json example: " + exampleValue, e);
    } catch (JsonProcessingException e) {
        throw new GenerationException("Unable to generate a schema for this json example: " + exampleValue, e);
    }
}
Also used : SchemaAware(com.fasterxml.jackson.databind.jsonschema.SchemaAware) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) GenerationException(org.jsonschema2pojo.exception.GenerationException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 28 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project jsonschema2pojo by joelittlejohn.

the class SchemaGenerator method objectSchema.

private ObjectNode objectSchema(JsonNode exampleObject) {
    ObjectNode schema = OBJECT_MAPPER.createObjectNode();
    schema.put("type", "object");
    ObjectNode properties = OBJECT_MAPPER.createObjectNode();
    for (Iterator<String> iter = exampleObject.fieldNames(); iter.hasNext(); ) {
        String property = iter.next();
        properties.set(property, schemaFromExample(exampleObject.get(property)));
    }
    schema.set("properties", properties);
    return schema;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 29 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project jsonschema2pojo by joelittlejohn.

the class SchemaGenerator method arraySchema.

private ObjectNode arraySchema(JsonNode exampleArray) {
    ObjectNode schema = OBJECT_MAPPER.createObjectNode();
    schema.put("type", "array");
    if (exampleArray.size() > 0) {
        JsonNode exampleItem = exampleArray.get(0).isObject() ? mergeArrayItems(exampleArray) : exampleArray.get(0);
        schema.set("items", schemaFromExample(exampleItem));
    }
    return schema;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 30 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project JsonPath by jayway.

the class JacksonJsonNodeJsonProvider method getMapValue.

@Override
public Object getMapValue(Object obj, String key) {
    ObjectNode jsonObject = toJsonObject(obj);
    Object o = jsonObject.get(key);
    if (!jsonObject.has(key)) {
        return UNDEFINED;
    } else {
        return unwrap(o);
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)702 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)174 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)157 JsonNode (com.fasterxml.jackson.databind.JsonNode)142 Test (org.junit.Test)111 StringEntity (org.apache.http.entity.StringEntity)88 Deployment (org.activiti.engine.test.Deployment)84 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)67 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)64 Task (org.activiti.engine.task.Task)49 HttpPost (org.apache.http.client.methods.HttpPost)49 JCodeModel (com.sun.codemodel.JCodeModel)45 JPackage (com.sun.codemodel.JPackage)44 HttpPut (org.apache.http.client.methods.HttpPut)40 JType (com.sun.codemodel.JType)39 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)39 IOException (java.io.IOException)38 HashMap (java.util.HashMap)38 ArrayList (java.util.ArrayList)28 Map (java.util.Map)28