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.
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}]}
-
Interface Summary Interface Description 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.JsValue Represents a json element of any type.Position Represents the location of a first-level element in a json, either a Key in a JsObj or an Index in a JsArray. -
Class Summary Class Description Index represents the index of a value in a json array.JsArray Represents a json array, which is an ordered list of elements.JsBigDec Represents an immutable json number of type BigDecimal.JsBigInt Represents an immutable json number of type BigInteger.JsBinary Represents an array of bytes.JsBool Represents an immutable json boolean.JsDouble Represents an immutable json number of type double.JsInstant Represents an immutable instant.JsInt Represents an immutable json number of type integer.JsLong Represents an immutable json number of type long.JsNothing It's a special json element that represents 'nothing'.JsNull Represents null, which a valid json value.JsNumber Represents an immutable json number.JsObj Represents a json object, which is an unordered set of name/element pairs.JsOptics represents optics defined for json objects and arraysJsOptics.JsArrayLenses represents all the lenses defined for a Json arrayJsOptics.JsArrayOptics represents all the optics defined for a Json arrayJsOptics.JsArrayOptionals represents all the S defined for a Json arrayJsOptics.JsObjLenses represents all the lenses defined for a Json objectJsOptics.JsObjOptics represents all the optics defined for a Json objectJsOptics.JsObjOptional represents all the S defined for a Json objectJsPath Represents the full path location of an element in a json.JsPrimitive JsStr Represents an immutable json string.Key represents the key of a value in a json object -
Enum Summary Enum Description JsArray.TYPE Type of arrays: SET, MULTISET or LIST. -
Exception Summary Exception Description MalformedJson Exception returned when a string can not be parsed into a Json or the json parsed has a different type than the expected.UserError Exception that models a programming error made by the user.