Package jsonvalues
Class JsObj
java.lang.Object
jsonvalues.JsObj
Represents an immutable JSON object. A JSON object is an unordered set of name/element pairs.
The underlying data structure is a persistent
HashMap
from the library vavr.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JsObj
the empty Json Objectstatic final JsOptics.JsObjLenses
lenses defined for a Json objectstatic final JsOptics.JsObjOptional
optionals defined for a Json objectprism between the sum type JsValue and JsObjstatic final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String key) return true if the key is presentboolean
containsValue
(JsValue el) Returns true if this json contains the given element in the first level.Removes the element in this json located at the given path, if it exists, returning the same this instance otherwisestatic JsObj
empty()
boolean
boolean
equals
(JsObj that, JsArray.TYPE ARRAY_AS) return true if this obj is equal to the given as a parameter.filterKeys
(BiPredicate<? super JsPath, ? super JsValue> filter) Filters all the keys of this json, removing those that don't ifPredicateElse the predicate.filterKeys
(Predicate<? super String> filter) Filters all the keys of this json, removing those that don't ifPredicateElse the predicate.filterObjs
(BiPredicate<? super JsPath, ? super JsObj> filter) Filters all the pair of jsons of this json, removing those that don't ifPredicateElse the predicate.filterObjs
(Predicate<? super JsObj> filter) Filters all the pair of jsons of this json, removing those that don't ifPredicateElse the predicate.filterValues
(BiPredicate<? super JsPath, ? super JsPrimitive> filter) Filters all the pairs of elements of this json, removing those that don't ifPredicateElse the predicate.filterValues
(Predicate<? super JsPrimitive> filter) Filters all the pairs of elements of this json, removing those that don't ifPredicateElse the predicate.Returns the element located at the given path orJsNothing
if it doesn't exist.Returns the array located at the given key or null if it doesn't exist, or it's not an array.Returns the array located at the given key or the default value provided if it doesn't exist or it's not an array.Returns the number located at the given key as a big decimal or null if it doesn't exist or it's not a decimal number.getBigDec
(String key, Supplier<BigDecimal> orElse) Returns the number located at the given key as a big decimal or the default value provided if it doesn't exist or it's not a decimal number.Returns the big integer located at the given key as a big integer or null if it doesn't exist or it's not an integral number.getBigInt
(String key, Supplier<BigInteger> orElse) Returns the big integer located at the given key as a big integer or the default value provided if it doesn't exist or it's not an integral number.byte[]
Returns the bytes located at the given key or null if it doesn't exist or it's not an array of bytes.byte[]
Returns the bytes located at the given key or the default value provided if it doesn't exist or it's not an array of bytes.Returns the boolean located at the given key or null if it doesn't exist.Returns the boolean located at the given key or the default value provided if it doesn't exist.Returns the number located at the given key as a double or null if it doesn't exist or it's not a decimal number.Returns the number located at the given key as a double or the default value provided if it doesn't exist or it's not a decimal number.getInstant
(String key) Returns the instant located at the given key or null if it doesn't exist or it's not an instant.getInstant
(String key, Supplier<Instant> orElse) Returns the instant located at the given key or the default value provided if it doesn't exist or it's not an instant.Returns the integral number located at the given key as an integer or null if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer.Returns the integral number located at the given key as an integer or the default value provided if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer.Returns the integral number located at the given key as a long or null if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long.Returns the integral number located at the given key as a long or the default value provided if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long.Returns the json object located at the given key or null if it doesn't exist or it's not an object.Returns the json object located at the given key or the default value provided if it doesn't exist or it's not an object.Returns the string located at the given key or null if it doesn't exist or it's not an string.Returns the string located at the given key or the default value provided if it doesn't exist or it's not an string.int
hashCode()
Returns the hashcode of the persistent LinkedHashMap from vavr, which is the data structure that holds the information.int
id()
intersection
(JsObj that, JsArray.TYPE ARRAY_AS) this.intersection(that, SET)
returns an array with the elements that exist in boththis
andthat
this.intersection(that, MULTISET)
returns an array with the elements that exist in boththis
andthat
, being duplicates allowed.boolean
isEmpty()
return true if there's no element in this jsonboolean
isObj()
Returns true if this JsValue is a JsObjiterator()
keySet()
Returns a set containing each key fo this object.mapKeys
(BiFunction<? super JsPath, ? super JsValue, String> fn) Maps all the keys of this json.Maps all the keys of this json.mapObjs
(BiFunction<? super JsPath, ? super JsObj, ? extends JsValue> fn) Maps all the jsons of this json.Maps all the jsons of this json.mapValues
(BiFunction<? super JsPath, ? super JsPrimitive, ? extends JsValue> fn) Maps all the values of this json.mapValues
(Function<? super JsPrimitive, ? extends JsValue> fn) Maps all the values of this json.static JsObj
static JsObj
static JsObj
static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17, String key18, JsValue el18) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17, String key18, JsValue el18, String key19, JsValue el19) static JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17, String key18, JsValue el18, String key19, JsValue el19, String key20, JsValue el20) static JsObj
static JsObj
static JsObj
static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17, JsPath path18, JsValue el18) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17, JsPath path18, JsValue el18, JsPath path19, JsValue el19) static JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17, JsPath path18, JsValue el18, JsPath path19, JsValue el19, JsPath path20, JsValue el20) static JsObj
Tries to parse the string into an immutable JSON object.<R> Optional<R>
reduce
(BinaryOperator<R> op, BiFunction<? super JsPath, ? super JsPrimitive, R> map, BiPredicate<? super JsPath, ? super JsPrimitive> predicate) Performs a reduction on the values of this json that satisfy the predicate.<R> Optional<R>
reduce
(BinaryOperator<R> op, Function<? super JsPrimitive, R> map, Predicate<? super JsPrimitive> predicate) Performs a reduction on the values of this json that satisfy the predicate.Inserts the element at the key in this json, replacing any existing element.Inserts the element at the path in this json, replacing any existing element and filling withJsNull
empty indexes in arrays when necessary.Inserts the element at the path in this json, replacing any existing element and filling with padElement empty indexes in arrays when necessary.int
size()
Returns the number of elements in the first level of this jsonstream()
Returns a stream over all the pairs of elements in this json object.toString()
union
(JsObj that, JsArray.TYPE ARRAY_AS) returnsthis
json object plus those pairs from the given json objectthat
which keys don't exist inthis
.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface jsonvalues.Json
containsPath, equals, getArray, getArray, getBigDec, getBigDec, getBigInt, getBigInt, getBinary, getBinary, getBool, getBool, getDouble, getDouble, getInstant, getInstant, getInt, getInt, getLong, getLong, getObj, getObj, getStr, getStr, ifEmptyElse, isNotEmpty, serialize, serialize, toJsPrimitive, toPrettyString, toPrettyString
Methods inherited from interface jsonvalues.JsValue
ifNothing, ifNull, isArray, isArray, isBigDec, isBigDec, isBigInt, isBigInt, isBinary, isBool, isDecimal, isDouble, isDouble, isFalse, isInstant, isInstant, isInt, isInt, isIntegral, isJson, isJson, isLong, isLong, isNothing, isNotNothing, isNotNull, isNotNumber, isNull, isNumber, isObj, isPrimitive, isSameType, isStr, isStr, isTrue, toJsArray, toJsBigDec, toJsBigInt, toJsBinary, toJsBool, toJsDouble, toJsInstant, toJsInt, toJsLong, toJsNumber, toJsObj, toJson, toJsStr
-
Field Details
-
EMPTY
the empty Json Object -
lens
lenses defined for a Json object -
optional
optionals defined for a Json object -
prism
prism between the sum type JsValue and JsObj -
TYPE_ID
public static final int TYPE_ID- See Also:
-
-
Constructor Details
-
JsObj
public JsObj()
-
-
Method Details
-
empty
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17, String key18, JsValue el18) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17, JsPath path18, JsValue el18) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17, String key18, JsValue el18, String key19, JsValue el19) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17, JsPath path18, JsValue el18, JsPath path19, JsValue el19) -
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5, String key6, JsValue el6, String key7, JsValue el7, String key8, JsValue el8, String key9, JsValue el9, String key10, JsValue el10, String key11, JsValue el11, String key12, JsValue el12, String key13, JsValue el13, String key14, JsValue el14, String key15, JsValue el15, String key16, JsValue el16, String key17, JsValue el17, String key18, JsValue el18, String key19, JsValue el19, String key20, JsValue el20) -
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5, JsPath path6, JsValue el6, JsPath path7, JsValue el7, JsPath path8, JsValue el8, JsPath path9, JsValue el9, JsPath path10, JsValue el10, JsPath path11, JsValue el11, JsPath path12, JsValue el12, JsPath path13, JsValue el13, JsPath path14, JsValue el14, JsPath path15, JsValue el15, JsPath path16, JsValue el16, JsPath path17, JsValue el17, JsPath path18, JsValue el18, JsPath path19, JsValue el19, JsPath path20, JsValue el20) -
parse
Tries to parse the string into an immutable JSON object.- Parameters:
str
- the string to be parsed- Returns:
- a JsOb object
- Throws:
JsParserException
- if the string doesn't represent a json object
-
set
Inserts the element at the key in this json, replacing any existing element.- Parameters:
key
- the keyvalue
- the element- Returns:
- a new json object
-
delete
-
containsValue
Description copied from interface:Json
Returns true if this json contains the given element in the first level.- Specified by:
containsValue
in interfaceJson<JsObj>
- Parameters:
el
- the give element JsValue whose presence in this JsArray is to be tested- Returns:
- true if this JsArray contains the JsValue
-
keySet
Returns a set containing each key fo this object.- Returns:
- a Set containing each key of this JsObj
-
get
Description copied from interface:Json
Returns the element located at the given path orJsNothing
if it doesn't exist. -
filterValues
Description copied from interface:Json
Filters all the pairs of elements of this json, removing those that don't ifPredicateElse the predicate.- Specified by:
filterValues
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as the input every JsPair of this json- Returns:
- same this instance if all the pairs satisfy the predicate or a new filtered json of the same type T
-
filterValues
Description copied from interface:Json
Filters all the pairs of elements of this json, removing those that don't ifPredicateElse the predicate.- Specified by:
filterValues
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as the input every JsPair of this json- Returns:
- same this instance if all the pairs satisfy the predicate or a new filtered json of the same type T
-
filterKeys
Description copied from interface:Json
Filters all the keys of this json, removing those that don't ifPredicateElse the predicate.- Specified by:
filterKeys
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as the input every JsPair of this json- Returns:
- same this instance if all the keys satisfy the predicate or a new filtered json of the same type T
-
filterKeys
Description copied from interface:Json
Filters all the keys of this json, removing those that don't ifPredicateElse the predicate.- Specified by:
filterKeys
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as the input every JsPair of this json- Returns:
- same this instance if all the keys satisfy the predicate or a new filtered json of the same type T
-
filterObjs
Description copied from interface:Json
Filters all the pair of jsons of this json, removing those that don't ifPredicateElse the predicate.- Specified by:
filterObjs
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as the input every JsPair of this json- Returns:
- same this instance if all the pairs satisfy the predicate or a new filtered json of the same type T
-
filterObjs
Description copied from interface:Json
Filters all the pair of jsons of this json, removing those that don't ifPredicateElse the predicate.- Specified by:
filterObjs
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as the input every JsPair of this json- Returns:
- same this instance if all the pairs satisfy the predicate or a new filtered json of the same type T
-
isEmpty
public boolean isEmpty()Description copied from interface:Json
return true if there's no element in this json -
mapValues
Description copied from interface:Json
Maps all the values of this json. -
mapValues
Description copied from interface:Json
Maps all the values of this json. -
mapKeys
Description copied from interface:Json
Maps all the keys of this json. -
mapKeys
Description copied from interface:Json
Maps all the keys of this json. -
mapObjs
Description copied from interface:Json
Maps all the jsons of this json. -
mapObjs
Description copied from interface:Json
Maps all the jsons of this json. -
set
Description copied from interface:Json
Inserts the element at the path in this json, replacing any existing element and filling with padElement empty indexes in arrays when necessary.The same instance is returned when the head of the path is a key and this is an array or the head of the path is an index and this is an object or the element is
JsNothing
- Specified by:
set
in interfaceJson<JsObj>
- Parameters:
path
- the JsPath object where the element will be inserted atvalue
- the JsValue that will be insertedpadElement
- the JsValue that will be inserted in arrays when padding is necessary- Returns:
- the same instance or a new json of the same type T
-
set
Description copied from interface:Json
Inserts the element at the path in this json, replacing any existing element and filling withJsNull
empty indexes in arrays when necessary.The same instance is returned when the head of the path is a key and this is an array or the head of the path is an index and this is an object or the element is
JsNothing
-
reduce
public <R> Optional<R> reduce(BinaryOperator<R> op, BiFunction<? super JsPath, ? super JsPrimitive, R> map, BiPredicate<? super JsPath, ? super JsPrimitive> predicate) Description copied from interface:Json
Performs a reduction on the values of this json that satisfy the predicate. The reduction is performed mapping each value with the mapping function and then applying the operator- Specified by:
reduce
in interfaceJson<JsObj>
- Type Parameters:
R
- the type of the operands of the operator- Parameters:
op
- the operator upon two objects of type Rmap
- the mapping function which produces an object of type R from a JsValuepredicate
- the predicate that determines what JsValue will be mapped and reduced- Returns:
- an
Optional
describing the result of the reduction
-
reduce
public <R> Optional<R> reduce(BinaryOperator<R> op, Function<? super JsPrimitive, R> map, Predicate<? super JsPrimitive> predicate) Description copied from interface:Json
Performs a reduction on the values of this json that satisfy the predicate. The reduction is performed mapping each value with the mapping function and then applying the operator- Specified by:
reduce
in interfaceJson<JsObj>
- Type Parameters:
R
- the type of the operands of the operator- Parameters:
op
- the operator upon two objects of type Rmap
- the mapping function which produces an object of type R from a JsValuepredicate
- the predicate that determines what JsValue will be mapped and reduced- Returns:
- an
Optional
describing the result of the reduction
-
delete
Description copied from interface:Json
Removes the element in this json located at the given path, if it exists, returning the same this instance otherwise -
size
public int size()Description copied from interface:Json
Returns the number of elements in the first level of this json -
stream
Description copied from interface:Json
Returns a stream over all the pairs of elements in this json object. -
equals
return true if this obj is equal to the given as a parameter. In the case of ARRAY_AS=LIST, this method is equivalent to JsObj.equals(Object).- Parameters:
that
- the given arrayARRAY_AS
- enum to specify if arrays are considered as lists or sets or multisets- Returns:
- true if both objs are equals
-
containsKey
return true if the key is present- Parameters:
key
- the key- Returns:
- true if the specified key exists
-
get
-
getArray
Returns the array located at the given key or null if it doesn't exist, or it's not an array.- Parameters:
key
- the key- Returns:
- the JsArray located at the given key or null
-
getArray
Returns the array located at the given key or the default value provided if it doesn't exist or it's not an array.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the JsArray located at the given key or the default value provided
-
getBigDec
Returns the number located at the given key as a big decimal or null if it doesn't exist or it's not a decimal number.- Parameters:
key
- the key- Returns:
- the BigDecimal located at the given key or null
-
getBigDec
Returns the number located at the given key as a big decimal or the default value provided if it doesn't exist or it's not a decimal number.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the BigDecimal located at the given key or the default value provided
-
getBinary
Returns the bytes located at the given key or null if it doesn't exist or it's not an array of bytes.- Parameters:
key
- the key- Returns:
- the bytes located at the given key or null
-
getBinary
Returns the bytes located at the given key or the default value provided if it doesn't exist or it's not an array of bytes.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the bytes located at the given key or the default value provided
-
getBigInt
Returns the big integer located at the given key as a big integer or null if it doesn't exist or it's not an integral number.- Parameters:
key
- the key- Returns:
- the BigInteger located at the given key or null
-
getBigInt
Returns the big integer located at the given key as a big integer or the default value provided if it doesn't exist or it's not an integral number.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the BigInteger located at the given key or null
-
getInstant
Returns the instant located at the given key or null if it doesn't exist or it's not an instant.- Parameters:
key
- the key- Returns:
- the instant located at the given key or null
-
getInstant
Returns the instant located at the given key or the default value provided if it doesn't exist or it's not an instant.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the instant located at the given key or null
-
getBool
Returns the boolean located at the given key or null if it doesn't exist.- Parameters:
key
- the key- Returns:
- the Boolean located at the given key or null
-
getBool
Returns the boolean located at the given key or the default value provided if it doesn't exist.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the Boolean located at the given key or null
-
getDouble
Returns the number located at the given key as a double or null if it doesn't exist or it's not a decimal number. If the number is a BigDecimal, the conversion is identical to the specified inBigDecimal.doubleValue()
and in some cases it can lose information about the precision of the BigDecimal- Parameters:
key
- the key- Returns:
- the decimal number located at the given key or null
-
getDouble
Returns the number located at the given key as a double or the default value provided if it doesn't exist or it's not a decimal number. If the number is a BigDecimal, the conversion is identical to the specified inBigDecimal.doubleValue()
and in some cases it can lose information about the precision of the BigDecimal- Parameters:
key
- the keyorElse
- the default value- Returns:
- the decimal number located at the given key or null
-
getInt
Returns the integral number located at the given key as an integer or null if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer.- Parameters:
key
- the key- Returns:
- the integral number located at the given key or null
-
getInt
Returns the integral number located at the given key as an integer or the default value provided if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the integral number located at the given key or null
-
getLong
Returns the integral number located at the given key as a long or null if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long.- Parameters:
key
- the key- Returns:
- the integral number located at the given key or null
-
getLong
Returns the integral number located at the given key as a long or the default value provided if it doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the integral number located at the given key or the default value provided
-
getObj
Returns the json object located at the given key or null if it doesn't exist or it's not an object.- Parameters:
key
- the key- Returns:
- the json object located at the given key or null
-
getObj
Returns the json object located at the given key or the default value provided if it doesn't exist or it's not an object.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the json object located at the given key or the default value
-
getStr
Returns the string located at the given key or null if it doesn't exist or it's not an string.- Parameters:
key
- the key- Returns:
- the string located at the given key or null
-
getStr
Returns the string located at the given key or the default value provided if it doesn't exist or it's not an string.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the string located at the given key or null
-
hashCode
public int hashCode()Returns the hashcode of the persistent LinkedHashMap from vavr, which is the data structure that holds the information. This method caches the hashcode once calculated. Since this is immutable, the hashcode won't change. It uses the single-check idiom Item 83 from Effective Java -
equals
-
toString
-
id
public int id() -
isObj
public boolean isObj()Description copied from interface:JsValue
Returns true if this JsValue is a JsObj -
intersection
this.intersection(that, SET)
returns an array with the elements that exist in boththis
andthat
this.intersection(that, MULTISET)
returns an array with the elements that exist in boththis
andthat
, being duplicates allowed. For those elements that are containers of the same type and are located at the same position, the result is their intersection. So this operation is kind of a 'recursive' intersection.- Specified by:
intersection
in interfaceJson<JsObj>
- Parameters:
that
- the other objectARRAY_AS
- option to define if arrays are considered SETS, LISTS OR MULTISET- Returns:
- a new JsObj of the same type as the inputs
-
iterator
-
union
returnsthis
json object plus those pairs from the given json objectthat
which keys don't exist inthis
. For those keys that exit in boththis
andthat
json objects, which associated elements are **containers of the same type**, the result is their union. In this case, we can specify if arrays are considered Sets, Lists, or MultiSets. So this operation is kind of a 'recursive' union.
-