Package jsonvalues.spec


package jsonvalues.spec
The `jsonvalues.spec` package provides classes and interfaces for defining and working with JSON specifications (specs) and parsers. JSON specifications describe the expected structure and constraints of JSON data, while parsers are used to validate and parse JSON data against these specifications.

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:
  • Class
    Description
    The `ERROR_CODE` enum represents various code codes that can be associated with validation errors when using JSON value specifications (`JsSpecs`).
    Represents a specification of a JSON array
    The JsArraySpecParser class is responsible for creating JSON array parsers based on provided JSON specifications (specs).
    Builder class for creating instances of JsEnum, which represents an enumeration of string symbols.
    Represents a code validating a value of a JSON
    Builder class for creating instances of JsFixedBinary, 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.
    The JsObjSpecBuilder class is a builder for creating instances of JsObjSpec with additional metadata.
     
    The JsObjSpecParser 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).
    The `SpecError` class represents a code that occurs during the validation of a JSON value against a specification.