Package jsonvalues


package jsonvalues
json-values is a one-package and zero-dependency library to work with jsons in a declarative and functional way. The main exceptions thrown by the library are the following:
  • the custom unchecked UserError, when the client makes a programming error. A suggestion in the message to avoid the error is returned.
  • the custom unchecked JsValuesInternalError, when something unexpected happens because a developer made a mistake. An issue in GitHub must be created
  • the checked MalformedJson, when a string can not be parsed into a json.
  • the unchecked NullPointerException, when a method different than equals receives a null parameter.
All the methods which name ends with all are applied to the whole json recursively, and not only to its first level. For example:
 
 x={"a":1, "b":[{"c":1, "d":true}]}
 x.size() = 2  // a and b
 x.size_() = 3 // a, b.0.c and b.0.1
 x.mapKeys(toUppercase)  =  {"A":1, "B":[{"c":1, "d":true}]}
 x.mapAllKeys(toUppercase) =  {"A":1, "B":[{"C":1, "D":true}]}
 
 
  • Class
    Description
    represents the index of a value in a json array.
    Represents a json array, which is an ordered list of elements.
    Type of arrays: SET, MULTISET or LIST.
    Represents an immutable json number of type BigDecimal.
    Represents an immutable json number of type BigInteger.
    Represents an array of bytes.
    JsBinaryLens<S extends Json<S>>
    Represent a Lens which focus is an array of bytes located at a path in a Json
    Represents an immutable json boolean.
    Represents an immutable json number of type double.
    Represents an immutable instant.
    JsInstantLens<S extends Json<S>>
    Represent a Lens which focus is an Instant located at a path in a Json
    Represents an immutable json number of type integer.
    Represents an immutable json number of type long.
    It's a special json element that represents 'nothing'.
    Represents null, which a valid json value.
    Represents an immutable json number.
    Represents a json object, which is an unordered set of name/element pairs.
    Json<T extends Json<T>>
    Represents a json of type T, where T is the type of the container, either a JsObj or a JsArray.
    represents optics defined for json objects and arrays
    represents all the lenses defined for a Json array
    represents all the optics defined for a Json array
    represents all the S defined for a Json array
    represents all the lenses defined for a Json object
    represents all the optics defined for a Json object
    represents all the S defined for a Json object
    Represents the full path location of an element in a json.
     
    Represents an immutable json string.
    Represents a json element of any type.
    represents the key of a value in a json object
    Exception returned when a string can not be parsed into a Json or the json parsed has a different type than the expected.
    Represents the location of a first-level element in a json, either a Key in a JsObj or an Index in a JsArray.
    Exception that models a programming error made by the user.