Package com.relogiclabs.jschema
Class JsonAssert
Object
JsonAssert
The class provides assertion functionalities to validate JSON documents against
a JSchema or JSON document.
-
Constructor Summary
ConstructorDescriptionJsonAssert
(String schema) Initializes a new instance of theJsonAssert
class for the specified JSchema string.JsonAssert
(String expected, TreeType type) Initializes a new instance of theJsonAssert
class for the specifiedexpected
string, which can be either a JSchema or a JSON representation. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Tests if the provided JSON strings are logically equivalent, meaning their structural composition and internal data are identical.void
Tests whether the input JSON string conforms to the expected JSchema or JSON specified in theJsonAssert
constructor.static void
Tests whether the specified JSON string conforms to the given JSchema string and throws an exception if the JSON string does not conform to the JSchema.
-
Constructor Details
-
JsonAssert
Initializes a new instance of theJsonAssert
class for the specified JSchema string.- Parameters:
schema
- A JSchema string for validation or conformation
-
JsonAssert
Initializes a new instance of theJsonAssert
class for the specifiedexpected
string, which can be either a JSchema or a JSON representation.- Parameters:
expected
- An expected JSchema or JSON string for validation or conformationtype
- The type of string provided byexpected
, indicating whether it represents a JSchema or JSON. UseTreeType.SCHEMA_TREE
for JSchema andTreeType.JSON_TREE
for JSON.
-
-
Method Details
-
isValid
Tests whether the input JSON string conforms to the expected JSchema or JSON specified in theJsonAssert
constructor.- Parameters:
json
- The actual input JSON to conform or validate
-
isValid
Tests whether the specified JSON string conforms to the given JSchema string and throws an exception if the JSON string does not conform to the JSchema.- Parameters:
schema
- The expected JSchema to conform or validatejson
- The actual JSON to conform or validate
-
areEqual
Tests if the provided JSON strings are logically equivalent, meaning their structural composition and internal data are identical. If the JSON strings are not equivalent, an exception is thrown.- Parameters:
expected
- The expected JSON to compareactual
- The actual JSON to compare
-
getRuntime
-
getExpectedTree
-