Package jsonvalues
json-values is a one-package and zero-dependency library to work with jsons in a declarative and functional way.
There are different static factory methods to create objects:
of
methods to create immutable objects or values from primitive types.parse
methods to parse strings into immutable objects or values._of_
methods to create mutable objects from primitive types._parse_
methods to parse strings into mutable objects.
- the unchecked UnsupportedOperationException, when the client makes a programming error.
- the checked MalformedJson, when a string can not be parsed into a json.
- the unchecked NullPointerException, when a method 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.mapKeys_(toUppercase) = {"A":1, "B":[{"C":1, "D":true}]}
-
Interface Summary Interface Description JsArray Represents a json array, which is an ordered list of elements.JsElem Represents a json element of any type.JsNumber Represents an immutable json number.JsObj 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.Position Represents the location of a first-level element in a json, either a Key in a JsObj or an Index in a JsArray.Trampoline<T> Trampolines allow to define recursive algorithms by iterative loops without blowing the stack when methods implementations are tail recursive. -
Class Summary Class Description Index Represents the index of a JsElem in a JsArray.JsBigDec Represents an immutable json number of type BigDecimal.JsBigInt Represents an immutable json number of type BigInteger.JsBool Represents an immutable json boolean.JsDouble Represents an immutable json number of type double.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.JsPair Immutable pair which represents a JsElem of a Json and its JsPath location: (path, element).JsPath Represents the full path location of an element in a json.JsStr Represents an immutable json string.Key Represents the Key of a JsElem in a JsObj.MatchExp Java doesn't support Pattern Matching but we can implement some matching expressions using high order functions.ParseOptions Builder with different options to customize the parsing of a string into a json.Try Computation that parses a string into a Json and may either result in a MalformedJson exception or a successfully parsed json.TryArr Computation that parses a string into a JsArray and may either result in a MalformedJson exception or a successfully parsed array.TryObj Computation that parses a string into a JsObj and may either result in a MalformedJson exception or a successfully parsed 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.