Class JsObj
Instances of this class are immutable and persistent, meaning that once created, the contents of a `JsObj` cannot be modified. Instead, operations on `JsObj` instances return new `JsObj` instances with the desired changes, leaving the original object unchanged. This immutability makes `JsObj` a persistent data structure.
This class provides methods to access and manipulate JSON data stored within it, including querying values by key, performing intersections with other `JsObj` instances, and converting the `JsObj` to a JSON string.
It also offers a convenient and functional way to work with JSON data in Java, making it easy to create and manipulate JSON objects programmatically.
Example usage:
// Create a JsObj with key-value pairs
JsObj person = JsObj.of("name", "Alice", "age", 30, "city", "New York");
// Access values by key
String name = person.getStr("name"); // "Alice"
int age = person.getInt("age"); // 30
// Create a new JsObj with additional data
JsObj updatedPerson = person.set("isStudent", true);
// Perform an intersection with another JsObj
JsObj otherPerson = JsObj.of("name", "Alice", "city", "London");
JsObj commonData = person.intersection(otherPerson, JsObj.TYPE.SET);
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JsOptics.JsObjLenses
Using thelens
field, you can apply various optical operations toJsObj
instances in a functional and declarative manner, making it easier to modify or query the content of aJsObj
static final JsOptics.JsObjOptional
Using theoptional
field, you can apply optional optics toJsObj
instances in a functional and declarative manner.A Prism that allows you to view aJsValue
as aJsObj
if it represents an object, or as an empty optional if it's not an object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String key) Checks if the specified key exists in the JSON object.boolean
containsValue
(JsValue el) Checks if this JSON contains the given value in its first level.Deletes the specified key from the JSON object.Removes the element at the specified path within this immutable JSON object, if it exists.static JsObj
empty()
Returns the singleton empty JSON objectboolean
boolean
equals
(JsObj that, JsArray.TYPE ARRAY_AS) Checks if this `JsObj` is equal to another `JsObj` considering how arrays are treated (as lists, sets, or multisets).filterKeys
(BiPredicate<? super JsPath, ? super JsValue> filter) Filters all the keys of this json, removing those that don't satisfy the given 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 satisfy the given 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 satisfy the given predicate.filterValues
(Predicate<? super JsPrimitive> filter) Filters all the pairs of elements of this json, removing those that don't ifPredicateElse the predicate.Retrieves the JSON value associated with the specified key.Gets the value 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.boolean
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.double
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.int
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.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 a string.Returns the string located at the given key or the default value provided if it doesn't exist, or it's not a string.int
hashCode()
intersection
(JsObj that, JsArray.TYPE ARRAY_AS) Computes the intersection of this JSON and another JSON object 'that' with respect to the given array merging strategy.boolean
isEmpty()
Determines whether this Json instance is empty, i.e., it contains no elements.boolean
isObj()
Returns true if this JsValue is a JsObj.iterator()
keySet()
Returns a `Set` of all keys present in the JSON object.mapKeys
(BiFunction<? super JsPath, ? super JsValue, String> fn) Maps all the keys of this JSON object, recursively traversing the entire JSON structure.Maps all the keys of this JSON object, recursively traversing the entire JSON structure.mapObjs
(BiFunction<? super JsPath, ? super JsObj, ? extends JsValue> fn) Maps all the JSON objects of this JSON, traversing the entire JSON if necessary.Maps all the JSON objects of this JSON, traversing the entire JSON if necessary.mapValues
(BiFunction<? super JsPath, ? super JsPrimitive, ? extends JsValue> fn) Recursively maps all the values of this JSON, replacing each value with the result of applying the given mapping function.mapValues
(Function<? super JsPrimitive, ? extends JsValue> fn) Recursively maps all the values of this JSON, replacing each value with the result of applying the given mapping function.static JsObj
Static factory method to create one-element JSON objectstatic JsObj
Static factory method to create two-element JSON objectstatic JsObj
Static factory method to create three-element JSON objectstatic JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4) Static factory method to create four-element JSON objectstatic JsObj
of
(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4, String key5, JsValue el5) Static factory method to create five-element JSON objectstatic 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 factory method to create six-element JSON objectstatic 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 factory method to create seven-element JSON objectstatic 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 factory method to create eight-element JSON objectstatic 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 factory method to create nine-element JSON objectstatic 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 factory method to create ten-element JSON objectstatic 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 factory method to create eleven-element JSON objectstatic 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 factory method to create twelve-element JSON objectstatic 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 factory method to create thirteen-element JSON objectstatic 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 factory method to create fourteen-element JSON objectstatic 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 factory method to create fifteen-element JSON objectstatic 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 factory method to create sixteen-element JSON objectstatic 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 factory method to create seventeen-element JSON objectstatic 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 factory method to create eighteen-element JSON objectstatic 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 factory method to create nineteen-element JSON objectstatic 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 factory method to create twenty-element JSON objectstatic 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, String key21, JsValue el21) 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, String key21, JsValue el21, String key22, JsValue el22) 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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23) 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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24) 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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25) 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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26) 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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26, String key27, JsValue el27) 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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26, String key27, JsValue el27, String key28, JsValue el28) 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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26, String key27, JsValue el27, String key28, JsValue el28, String key29, JsValue el29) static JsObj
Static factory method to create one-element JSON objectstatic JsObj
Static factory method to create two-element JSON objectstatic JsObj
Static factory method to create three-element JSON objectstatic JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4) Static factory method to create four-element JSON objectstatic JsObj
of
(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4, JsPath path5, JsValue el5) Static factory method to create five-element JSON objectstatic 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 factory method to create six-element JSON objectstatic 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 factory method to create seven-element JSON objectstatic 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 factory method to create eight-element JSON objectstatic 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 factory method to create nine-element JSON objectstatic 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 factory method to create ten-element JSON objectstatic 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 factory method to create eleven-element JSON objectstatic 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 factory method to create twelve-element JSON objectstatic 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 factory method to create thirteen-element JSON objectstatic 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 factory method to create fourteen-element JSON objectstatic 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 factory method to create fifteen-element JSON objectstatic 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 factory method to create sixteen-element JSON objectstatic 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 factory method to create seventeen-element JSON objectstatic 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 factory method to create eighteen-element JSON objectstatic 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 factory method to create nineteen-element JSON objectstatic 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 factory method to create twenty-element JSON objectstatic JsObj
Creates a JsObj from a Map of keys and JsValue.static JsObj
ofMapOfDouble
(Map<String, Double> map) Creates a JsObj from a Map of String keys and Double .static JsObj
ofMapOfInt
(Map<String, Integer> map) Creates a JsObj from a Map of keys and Integer.static JsObj
ofMapOfLong
(Map<String, Long> map) Creates a JsObj from a Map of String keys and Long.static JsObj
ofMapOfStr
(Map<String, String> map) Creates a JsObj from a Map of keys and String.static JsObj
parse
(byte[] bytes) Parses the given array of bytes into an immutable and persistent JSON object.static JsObj
Parses the given string into an immutable and persistent JSON object.<R> R
reduce
(BinaryOperator<R> op, BiFunction<? super JsPath, ? super JsPrimitive, R> map, BiPredicate<? super JsPath, ? super JsPrimitive> predicate) Reduces the values of this JSON object that satisfy the given predicate, allowing access to the element's path.<R> R
reduce
(BinaryOperator<R> op, Function<? super JsPrimitive, R> map, Predicate<? super JsPrimitive> predicate) Reduces the values of this JSON object that satisfy the given predicate.Sets the value of the specified key in this JSON object to a boolean value.Sets the value of the specified key in this JSON object to an integer value.Sets the value of the specified key in this JSON object to a long value.Sets the value of the specified key in this JSON object to a Double value.Sets the value of the specified key in this JSON object to a string value.set
(String key, BigDecimal value) Sets the value of the specified key in this JSON object to a BigDecimal value.Sets the value of the specified key in this JSON object to an Instant value.Sets the specified key to the given JSON value.Sets the value of the specified path in this JSON object to a boolean value.Sets the value of the specified path in this JSON object to an integer value.Sets the value of the specified path in this JSON object to a long value.Sets the value of the specified path in this JSON object to a Double value.Sets the value of the specified path in this JSON object to a string value.set
(JsPath path, BigDecimal value) Sets the value of the specified path in this JSON object to a BigDecimal value.Sets the value of the specified path in this JSON object to an Instant value.Inserts the given element at the specified path in this JSON, replacing any existing element.Inserts an element at the specified path in this JSON, replacing any existing element.int
size()
Returns the number of elements in the first level of this JSON object or array.stream()
Returns a stream over all the key-value pairsJsPair
of elements in this JSON object.Returns a stream of `(key, value)` pairs representing the properties of the JSON object at the first level.toString()
union
(JsObj that, JsArray.TYPE ARRAY_AS) Computes the union of this JSON and another JSON object 'that' with respect to the given array merging strategy.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
-
lens
Using thelens
field, you can apply various optical operations toJsObj
instances in a functional and declarative manner, making it easier to modify or query the content of aJsObj
-
optional
Using the
optional
field, you can apply optional optics toJsObj
instances in a functional and declarative manner. These optics allow you to safely retrieve and modify fields that may or may not be present in theJsObj
, helping you avoid null pointer exceptions and handle optional values gracefully. -
prism
A Prism that allows you to view aJsValue
as aJsObj
if it represents an object, or as an empty optional if it's not an object.Prisms are a functional optic that can be used to safely extract a specific type from a more general type, or to construct a more general type from a specific type. In this case, the
prism
field allows you to view aJsValue
as aJsObj
only if it represents an object, and returns an empty optional if theJsValue
is not an object.This Prism is useful for safely handling and processing JSON data, ensuring that you only work with objects when you expect them to be objects.
-
-
Method Details
-
ofMap
Creates a JsObj from a Map of keys and JsValue.- Parameters:
map
- The input Map with String keys and JsValue values.- Returns:
- A JsObj created from the input Map.
-
ofMapOfStr
Creates a JsObj from a Map of keys and String.- Parameters:
map
- The input Map with String keys and String values.- Returns:
- A JsObj created from the input Map.
-
ofMapOfInt
Creates a JsObj from a Map of keys and Integer.- Parameters:
map
- The input Map with String keys and Integer values.- Returns:
- A JsObj created from the input Map.
-
ofMapOfLong
Creates a JsObj from a Map of String keys and Long.- Parameters:
map
- The input Map with String keys and Long .- Returns:
- A JsObj created from the input Map.
-
ofMapOfDouble
Creates a JsObj from a Map of String keys and Double .- Parameters:
map
- The input Map with String keys and Double.- Returns:
- A JsObj created from the input Map.
-
empty
Returns the singleton empty JSON object- Returns:
- the singleton empty JSON object
-
of
Static factory method to create one-element JSON object- Returns:
- an immutable and persistent JSON object
-
of
Static factory method to create one-element JSON object- Returns:
- an immutable and persistent JSON object
-
of
Static factory method to create two-element JSON object- Returns:
- an immutable and persistent JSON object
-
of
Static factory method to create two-element JSON object- Returns:
- an immutable and persistent JSON object
-
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3) Static factory method to create three-element JSON object- Returns:
- an immutable and persistent JSON object
-
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3) Static factory method to create three-element JSON object- Returns:
- an immutable and persistent JSON object
-
of
public static JsObj of(String key1, JsValue el1, String key2, JsValue el2, String key3, JsValue el3, String key4, JsValue el4) Static factory method to create four-element JSON object- Returns:
- an immutable and persistent JSON object
-
of
public static JsObj of(JsPath path1, JsValue el1, JsPath path2, JsValue el2, JsPath path3, JsValue el3, JsPath path4, JsValue el4) Static factory method to create four-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create five-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create five-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create six-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create six-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create seven-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create seven-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create eight-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create eight-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create nine-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create nine-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create ten-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create ten-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create eleven-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create eleven-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create twelve-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create twelve-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create thirteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create thirteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create fourteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create fourteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create fifteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create fifteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create sixteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create sixteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create seventeen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create seventeen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create eighteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create eighteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create nineteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create nineteen-element JSON object- Returns:
- an immutable and persistent JSON object
-
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) Static factory method to create twenty-element JSON object- Returns:
- an immutable and persistent JSON object
-
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, String key21, JsValue el21) -
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, String key21, JsValue el21, String key22, JsValue el22) -
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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23) -
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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24) -
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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25) -
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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26) -
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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26, String key27, JsValue el27) -
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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26, String key27, JsValue el27, String key28, JsValue el28) -
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, String key21, JsValue el21, String key22, JsValue el22, String key23, JsValue el23, String key24, JsValue el24, String key25, JsValue el25, String key26, JsValue el26, String key27, JsValue el27, String key28, JsValue el28, String key29, JsValue el29) -
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) Static factory method to create twenty-element JSON object- Returns:
- an immutable and persistent JSON object
-
parse
Parses the given string into an immutable and persistent JSON object.- Parameters:
str
- the string to be parsed- Returns:
- a JsOb object
- Throws:
JsParserException
- if the string doesn't represent a json object
-
parse
Parses the given array of bytes into an immutable and persistent JSON object.- Parameters:
bytes
- the array of bytes- Returns:
- a JsObj object
- Throws:
JsParserException
- if the string doesn't represent a json object
-
set
Sets the value of the specified key in this JSON object to a string value. If the key does not exist, it will be created.- Parameters:
key
- The key to set.value
- The string value to set.- Returns:
- A new JSON object with the specified key and value.
-
set
Sets the value of the specified key in this JSON object to an integer value. If the key does not exist, it will be created.- Parameters:
key
- The key to set.value
- The integer value to set.- Returns:
- A new JSON object with the specified key and value.
-
set
Sets the value of the specified key in this JSON object to a long value. If the key does not exist, it will be created.- Parameters:
key
- The key to set.value
- The long value to set.- Returns:
- A new JSON object with the specified key and value.
-
set
Sets the value of the specified key in this JSON object to a boolean value. If the key does not exist, it will be created.- Parameters:
key
- The key to set.value
- The boolean value to set.- Returns:
- A new JSON object with the specified key and value.
-
set
Sets the value of the specified key in this JSON object to an Instant value. If the key does not exist, it will be created.- Parameters:
key
- The key to set.value
- The Instant value to set.- Returns:
- A new JSON object with the specified key and value.
-
set
Sets the value of the specified key in this JSON object to a BigDecimal value. If the key does not exist, it will be created.- Parameters:
key
- The key to set.value
- The BigDecimal value to set.- Returns:
- A new JSON object with the specified key and value.
-
set
Sets the value of the specified key in this JSON object to a Double value. If the key does not exist, it will be created.- Parameters:
key
- The key to set.value
- The Double value to set.- Returns:
- A new JSON object with the specified key and value.
-
set
Sets the value of the specified path in this JSON object to a string value. If the path does not exist, it will be created.- Parameters:
path
- The path to set.value
- The string value to set.- Returns:
- A new JSON object with the specified path and value.
-
set
Sets the value of the specified path in this JSON object to an integer value. If the path does not exist, it will be created.- Parameters:
path
- The path to set.value
- The integer value to set.- Returns:
- A new JSON object with the specified path and value.
-
set
Sets the value of the specified path in this JSON object to a long value. If the path does not exist, it will be created.- Parameters:
path
- The path to set.value
- The long value to set.- Returns:
- A new JSON object with the specified path and value.
-
set
Sets the value of the specified path in this JSON object to a boolean value. If the path does not exist, it will be created.- Parameters:
path
- The path to set.value
- The boolean value to set.- Returns:
- A new JSON object with the specified path and value.
-
set
Sets the value of the specified path in this JSON object to an Instant value. If the path does not exist, it will be created.- Parameters:
path
- The path to set.value
- The Instant value to set.- Returns:
- A new JSON object with the specified path and value.
-
set
Sets the value of the specified path in this JSON object to a BigDecimal value. If the path does not exist, it will be created.- Parameters:
path
- The path to set.value
- The BigDecimal value to set.- Returns:
- A new JSON object with the specified path and value.
-
set
Sets the value of the specified path in this JSON object to a Double value. If the path does not exist, it will be created.- Parameters:
path
- The path to set.value
- The Double value to set.- Returns:
- A new JSON object with the specified path and value.
-
set
Sets the specified key to the given JSON value. If the key already exists, its value will be updated. If the key doesn't exist, a new key-value pair will be added to the JSON object.- Parameters:
key
- The key to set.value
- The JSON value to associate with the key.- Returns:
- A new `JsObj` with the updated or added key-value pair.
-
delete
Deletes the specified key from the JSON object. If the key doesn't exist, this method has no effect.- Parameters:
key
- The key to delete.- Returns:
- A new `JsObj` with the specified key removed.
-
containsValue
Description copied from interface:Json
Checks if this JSON contains the given value in its first level.- Specified by:
containsValue
in interfaceJson<JsObj>
- Parameters:
el
- The value to check for.- Returns:
- True if this JSON contains the value, otherwise false.
-
keySet
Returns a `Set` of all keys present in the JSON object.- Returns:
- A `Set` of all keys in the JSON object.
-
get
Description copied from interface:Json
Gets the value 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 satisfy the given predicate.- Specified by:
filterValues
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as input every JsPair of this json- Returns:
- 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 satisfy the given predicate.- Specified by:
filterKeys
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as input every JsPair of this json- Returns:
- 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 satisfy the given predicate.- Specified by:
filterObjs
in interfaceJson<JsObj>
- Parameters:
filter
- the predicate which takes as input every JsPair of this json- Returns:
- 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
Determines whether this Json instance is empty, i.e., it contains no elements. -
mapValues
Description copied from interface:Json
Recursively maps all the values of this JSON, replacing each value with the result of applying the given mapping function. This operation traverses the entire JSON structure. -
mapValues
Description copied from interface:Json
Recursively maps all the values of this JSON, replacing each value with the result of applying the given mapping function. This operation traverses the entire JSON structure. -
mapKeys
Description copied from interface:Json
Maps all the keys of this JSON object, recursively traversing the entire JSON structure. -
mapKeys
Description copied from interface:Json
Maps all the keys of this JSON object, recursively traversing the entire JSON structure. -
mapObjs
Description copied from interface:Json
Maps all the JSON objects of this JSON, traversing the entire JSON if necessary. -
mapObjs
Description copied from interface:Json
Maps all the JSON objects of this JSON, traversing the entire JSON if necessary. -
set
Description copied from interface:Json
Inserts an element at the specified path in this JSON, replacing any existing element. -
set
Description copied from interface:Json
Inserts the given element at the specified path in this JSON, replacing any existing element. If necessary, it fills empty indexes in arrays withJsNull
. You have the option to useJson.set(JsPath, JsValue, JsValue)
to specify a custom padding element. -
reduce
public <R> R reduce(BinaryOperator<R> op, BiFunction<? super JsPath, ? super JsPrimitive, R> map, BiPredicate<? super JsPath, ? super JsPrimitive> predicate) Description copied from interface:Json
Reduces the values of this JSON object that satisfy the given predicate, allowing access to the element's path. This reduction traverses the entire JSON recursively if necessary.- Specified by:
reduce
in interfaceJson<JsObj>
- Type Parameters:
R
- the type of the reduction result- Parameters:
op
- the operator to apply to values of type Rmap
- the mapping function to convert JsPath and JsPrimitive to type Rpredicate
- the predicate that determines which values are included in the reduction- Returns:
- an
Optional
describing the result of the reduction, or empty if no values satisfy the predicate
-
reduce
public <R> R reduce(BinaryOperator<R> op, Function<? super JsPrimitive, R> map, Predicate<? super JsPrimitive> predicate) Description copied from interface:Json
Reduces the values of this JSON object that satisfy the given predicate. This reduction traverses the entire JSON recursively if necessary.- Specified by:
reduce
in interfaceJson<JsObj>
- Type Parameters:
R
- the type of the reduction result- Parameters:
op
- the operator to apply to values of type Rmap
- the mapping function to convert JsValue to type Rpredicate
- the predicate that determines which values are included in the reduction- Returns:
- an
Optional
describing the result of the reduction, or empty if no values satisfy the predicate
-
delete
Description copied from interface:Json
Removes the element at the specified path within this immutable JSON object, if it exists. Returns a new JSON object with the element removed, or the original JSON object if the element does not exist. -
size
public int size()Description copied from interface:Json
Returns the number of elements in the first level of this JSON object or array. This method provides the count of elements directly contained in the JSON object or array. -
stream
Description copied from interface:Json
Returns a stream over all the key-value pairsJsPair
of elements in this JSON object. This method provides a way to traverse and operate on the key-value pairs within the JSON object. -
streamOfKeys
Returns a stream of `(key, value)` pairs representing the properties of the JSON object at the first level. This method operates on the top-level properties and does not traverse recursively into nested JSON objects.- Returns:
- A stream of `(key, value)` pairs, where each pair consists of a top-level property key and its corresponding value.
-
equals
Checks if this `JsObj` is equal to another `JsObj` considering how arrays are treated (as lists, sets, or multisets).- Parameters:
that
- The `JsObj` to compare with.ARRAY_AS
- Enum to specify how arrays are considered.- Returns:
- `true` if both `JsObj` instances are equal; otherwise, `false`.
-
containsKey
Checks if the specified key exists in the JSON object.- Parameters:
key
- The key to check for existence.- Returns:
- `true` if the key exists; otherwise, `false`.
-
get
Retrieves the JSON value associated with the specified key.- Parameters:
key
- The key to retrieve the JSON value for.- Returns:
- The JSON value associated with the key or a default value if the key does not exist.
-
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 a 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 a string.- Parameters:
key
- the keyorElse
- the default value- Returns:
- the string located at the given key or null
-
hashCode
public int hashCode() -
equals
-
toString
-
isObj
public boolean isObj()Description copied from interface:JsValue
Returns true if this JsValue is a JsObj. -
intersection
Description copied from interface:Json
Computes the intersection of this JSON and another JSON object 'that' with respect to the given array merging strategy. The intersection of two JSON objects is another JSON object that contains only the key-value pairs present in both 'this' and 'that'. Array merging strategy 'ARRAY_AS' determines how arrays are merged during the intersection operation. If 'ARRAY_AS' is 'MERGE', arrays are merged by concatenating elements. If 'ARRAY_AS' is 'REPLACE', arrays in 'this' will be replaced with arrays from 'that'.- Specified by:
intersection
in interfaceJson<JsObj>
- Parameters:
that
- the other JSON object to compute the intersection withARRAY_AS
- the array merging strategy, either 'MERGE' or 'REPLACE'- Returns:
- a new JSON object representing the intersection of 'this' and 'that'
-
iterator
-
union
Description copied from interface:Json
Computes the union of this JSON and another JSON object 'that' with respect to the given array merging strategy. The union of two JSON objects is another JSON object that contains all the key-value pairs present in either 'this' or 'that'. If a key is present in both JSON objects, the value from 'this' will be used. Array merging strategy 'ARRAY_AS' determines how arrays are merged during the union operation. If 'ARRAY_AS' is 'MERGE', arrays are merged by concatenating elements. If 'ARRAY_AS' is 'REPLACE', arrays in 'this' will be replaced with arrays from 'that'.
-