LazyValue
struct LazyValueA lazily-parsed JSON value.
Unlike Value, LazyValue stores the raw JSON and only parses when you access specific fields or elements. This is efficient for large documents where you only need a few values.
Example: var lazy = loads_lazy(huge_json_string) var name = lazy.get("/users/0/name") Only parses the path to "users/0/name", not the whole document.
Implements Movable
__init__
def __init__(out self, raw: String) Create a LazyValue from raw JSON string.
__getitem__
def __getitem__(self, key: String) -> Self Get object field as a new LazyValue.
- Args
key: Object key.
def __getitem__(self, index: Int) -> Self Get array element as a new LazyValue.
- Args
index: Array index.
is_null
def is_null(mut self) -> Bool Check if value is null.
is_bool
def is_bool(mut self) -> Bool Check if value is a boolean.
is_int
def is_int(mut self) -> Bool Check if value is an integer.
is_float
def is_float(mut self) -> Bool Check if value is a float.
is_string
def is_string(mut self) -> Bool Check if value is a string.
is_array
def is_array(mut self) -> Bool Check if value is an array.
is_object
def is_object(mut self) -> Bool Check if value is an object.
raw
def raw(self) -> String Get the raw JSON string.
get
def get(self, pointer: String) -> Value Get a value at the given JSON Pointer path.
Only parses the necessary parts of the JSON to reach the target.
Example: var name = lazy.get("/users/0/name").
- Args
pointer: JSON Pointer path (e.g., "/users/0/name").
get_string
def get_string(self, pointer: String) -> String Get a string value at the given path.
- Args
pointer: JSON Pointer path.
get_int
def get_int(self, pointer: String) -> Int64 Get an integer value at the given path.
- Args
pointer: JSON Pointer path.
get_bool
def get_bool(self, pointer: String) -> Bool Get a boolean value at the given path.
- Args
pointer: JSON Pointer path.
parse
def parse(self) -> Value Fully parse the JSON into a Value.
Use this when you need the complete parsed structure. For accessing specific fields, use get() instead.