Class JsonValidator


  • public class JsonValidator
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonValidator()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static com.fasterxml.jackson.databind.JsonNode getJsonNodeFromFile​(java.lang.String name)
      get a JsonNode from a file on the classpath
      static com.fasterxml.jackson.databind.JsonNode getJsonNodeFromStringContent​(java.lang.String content)
      Takes a JSON string and returns a JsonNode object
      static com.networknt.schema.JsonSchema getJsonSchemaFromFile​(java.lang.String name)
      Get a JsonSchema from a file on the classpath
      static com.networknt.schema.JsonSchema getJsonSchemaFromStringContent​(java.lang.String schemaContent)
      Takes a JSON string and gives a JsonSchema object
      java.util.Set<com.networknt.schema.ValidationMessage> isForward​(com.fasterxml.jackson.databind.JsonNode node)
      Tests if a given message is a well-formed JSON 'forward' message
      java.util.Set<com.networknt.schema.ValidationMessage> isReply​(com.fasterxml.jackson.databind.JsonNode node)
      Tests if a given message is a well-formed JSON 'reply' message
      java.util.Set<com.networknt.schema.ValidationMessage> isRequest​(com.fasterxml.jackson.databind.JsonNode node)
      Tests if a given message is a well-formed JSON 'request' message
      java.util.Set<com.networknt.schema.ValidationMessage> isRoot​(com.fasterxml.jackson.databind.JsonNode node)
      Tests if a given message is a well-formed JSON 'root' message
      java.util.Set<com.networknt.schema.ValidationMessage> isShard​(com.fasterxml.jackson.databind.JsonNode node)
      Tests if a given message is a well-formed JSON 'shard' message
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonValidator

        public JsonValidator()
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • isRoot

        public java.util.Set<com.networknt.schema.ValidationMessage> isRoot​(com.fasterxml.jackson.databind.JsonNode node)
        Tests if a given message is a well-formed JSON 'root' message
        Parameters:
        node - a JsonNode message
        Returns:
        a set of error ValidationMessage - if it has a size of 0, it is a well formed message
      • isShard

        public java.util.Set<com.networknt.schema.ValidationMessage> isShard​(com.fasterxml.jackson.databind.JsonNode node)
        Tests if a given message is a well-formed JSON 'shard' message
        Parameters:
        node - a JsonNode message
        Returns:
        a set of error ValidationMessage - if it has a size of 0, it is a well formed message
      • isRequest

        public java.util.Set<com.networknt.schema.ValidationMessage> isRequest​(com.fasterxml.jackson.databind.JsonNode node)
        Tests if a given message is a well-formed JSON 'request' message
        Parameters:
        node - a JsonNode message
        Returns:
        a set of error ValidationMessage - if it has a size of 0, it is a well formed message
      • isReply

        public java.util.Set<com.networknt.schema.ValidationMessage> isReply​(com.fasterxml.jackson.databind.JsonNode node)
        Tests if a given message is a well-formed JSON 'reply' message
        Parameters:
        node - a JsonNode message
        Returns:
        a set of error ValidationMessage - if it has a size of 0, it is a well formed message
      • isForward

        public java.util.Set<com.networknt.schema.ValidationMessage> isForward​(com.fasterxml.jackson.databind.JsonNode node)
        Tests if a given message is a well-formed JSON 'forward' message
        Parameters:
        node - a JsonNode message
        Returns:
        a set of error ValidationMessage - if it has a size of 0, it is a well formed message
      • getJsonNodeFromStringContent

        public static com.fasterxml.jackson.databind.JsonNode getJsonNodeFromStringContent​(java.lang.String content)
                                                                                    throws java.lang.Exception
        Takes a JSON string and returns a JsonNode object
        Parameters:
        content - a string which should be well-formed JSON
        Returns:
        a JsonNode object
        Throws:
        java.lang.Exception - if there is a parsing error
      • getJsonSchemaFromStringContent

        public static com.networknt.schema.JsonSchema getJsonSchemaFromStringContent​(java.lang.String schemaContent)
                                                                              throws java.lang.Exception
        Takes a JSON string and gives a JsonSchema object
        Parameters:
        schemaContent - a json-schema.org schema
        Returns:
        a JsonSchema object
        Throws:
        java.lang.Exception - if there is a problem parsing
      • getJsonNodeFromFile

        public static com.fasterxml.jackson.databind.JsonNode getJsonNodeFromFile​(java.lang.String name)
                                                                           throws java.lang.Exception
        get a JsonNode from a file on the classpath
        Parameters:
        name - a filename
        Returns:
        a JsonNode
        Throws:
        java.lang.Exception - if there is a parsing error
      • getJsonSchemaFromFile

        public static com.networknt.schema.JsonSchema getJsonSchemaFromFile​(java.lang.String name)
                                                                     throws java.lang.Exception
        Get a JsonSchema from a file on the classpath
        Parameters:
        name - a filename
        Returns:
        a JsonSchema object
        Throws:
        java.lang.Exception - if there is an error parsing