Package jsonvalues

Class JsObj

java.lang.Object
jsonvalues.JsObj
All Implemented Interfaces:
Iterable<JsObjPair>, Json<JsObj>, JsValue

public final class JsObj extends Object implements Json<JsObj>, Iterable<JsObjPair>
Represents a JSON object in a lightweight, immutable, and functional manner. A `JsObj` consists of a collection of key-value pairs, where the keys are strings and the values can be various JSON data types such as strings, numbers, booleans, arrays, or nested objects.

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);