All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.etlunit.json.validator.JsonSchema Maven / Gradle / Ivy

The newest version!
package org.etlunit.json.validator;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.node.ObjectNode;

import java.io.File;
import java.io.IOException;

public class JsonSchema {
	private final JsonSchemaObjectNode jsonSchemaObjectNode;

	public JsonSchema(JsonNode root) throws JsonSchemaValidationException
	{
		if (!root.isObject())
		{
			throw new JsonSchemaValidationException("Invalid schema - not object type", "", root, null);
		}

		jsonSchemaObjectNode = new JsonSchemaObjectNode((ObjectNode) root);
	}

	public JsonSchema(String schema) throws JsonSchemaValidationException
	{
		this(JsonUtils.loadJson(schema));
	}

	JsonSchema(JsonSchemaObjectNode objectNode) throws JsonSchemaValidationException
	{
		jsonSchemaObjectNode = objectNode;
	}

	public String getId()
	{
		return jsonSchemaObjectNode.getId();
	}

	public JsonSchemaObjectNode getSchemaNode()
	{
		return jsonSchemaObjectNode;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy