Package jsonvalues.spec
JSON Specifications (Specs):
The core concept in this package is the JSON specification, represented by various interfaces such as
JsSpec
, JsArraySpec
, and JsObjSpec
. These
specifications define the schema and validation rules for JSON data, ensuring that it adheres to the expected
structure.
- JsSpec
: An interface that represents a generic JSON specification. Implementations of this
interface can be used to specify constraints on JSON data types.
- JsArraySpec
: An interface that extends `JsSpec` and is used to define specifications for
JSON arrays. It allows you to specify constraints on the elements within a JSON array.
- JsObjSpec
: An interface that extends `JsSpec` and is used to define specifications for JSON
objects (maps). It allows you to specify constraints on the keys and values within a JSON object.
JSON Parsers:
JSON parsers, represented by classes like JsParser
, are used to validate and parse JSON data
based on the provided JSON specifications. Parsers ensure that the input JSON data conforms to the specified schema.
- JsParser
: A class used to create JSON data parsers from JSON specifications. These parsers
validate input JSON data against the specified schema and return the parsed JSON data if it conforms.
- JsArraySpecParser
: A class for creating JSON array parsers from array specifications. These
parsers validate and parse JSON arrays against the defined schema.
- JsObjSpecParser
: A class for creating JSON object parsers from object specifications. These
parsers validate and parse JSON objects against the specified schema.
Usage:
To use the classes and interfaces in this package, you typically follow these steps:
1. Define a JSON specification using one of the `JsSpec` implementations like `JsArraySpec` or `JsObjSpec`. Specify the expected structure and constraints for JSON data.
2. Create a JSON parser using the corresponding parser class, such as `JsArraySpecParser` or `JsObjSpecParser`, passing in the JSON specification.
3. Use the parser to validate and parse JSON data. If the input data conforms to the specification, the parser returns the parsed JSON data; otherwise, it raises an exception indicating the validation failure.
- See Also:
-
ClassDescriptionA class representing the schema for arrays in a JSON structure.A class representing the schema for BigDecimal values in a JSON spec.A class representing the schema for double values in a JSON spec.The `ERROR_CODE` enum represents various code codes that can be associated with validation errors when using JSON value specifications (`JsSpecs`).A class representing the schema for instant values in a JSON spec.A class representing the schema for integer values in a JSON spec.Represents a specification of a JSON arrayThe
JsArraySpecParser
class is responsible for creating JSON array parsers based on provided JSON specifications (specs).Builder class for creating instances ofJsEnum
, which represents an enumeration of string symbols.Represents a code validating a value of a JSONBuilder class for creating instances ofJsFixedBinary
, which represents a fixed-size binary type.Singleton instance to create JSON readers and writers to parse bytes into JSON and serialize JSON into bytes.Represents a specification of a JSON object, allowing you to define rules and constraints for validating JSON objects.TheJsObjSpecBuilder
class is a builder for creating instances ofJsObjSpec
with additional metadata.TheJsObjSpecParser
class is responsible for creating JSON object parsers based on provided JSON specifications (specs).Represent an exception that is thrown while parsing an array of bytes or string into a JSON.Represent an exception that is thrown while serializing a JSON into an array of bytes.The `JsSpec` interface represents a specification for validating JSON data structures.The `JsSpecs` class provides a collection of static factory methods for creating JSON specifications (JsSpec).A class representing the schema for long values in a JSON spec.The `SpecError` class represents a code that occurs during the validation of a JSON value against a specification.The `SpecGenConfBuilder` class is responsible for configuring the generation parameters used by `SpecToGen`.Class responsible for converting JSON specs to JSON generators.This class is designed for converting JSON specifications into JSON schemas represented by a JsObj.A class representing the schema for string values in a JSON structure.