pub enum JSONValue<'a> {
Null,
Boolean(bool),
Number(f64),
String(AtomBytes),
Array(&'a [&'a JSONValue<'a>]),
Object(&'a JSONHiddenClass<'a>, &'a [&'a JSONValue<'a>]),
}Expand description
The base type for all JSON values (JSONParser.h:49). &'a JSONValue<'a> IS
the C++ JSONValue*: nodes live in a bumpalo arena; the variant replaces
the kind tag + LLVM RTTI; arena identity gives pointer equality.
Variants§
Null
null. A singleton within a JSONFactory.
Boolean(bool)
true or false. Two singletons within a JSONFactory.
Number(f64)
A number, already converted to f64. Uniqued by bit pattern, so
-0.0 and 0.0 are distinct nodes.
String(AtomBytes)
A string, interned in the AtomTable and uniqued by that handle.
Array(&'a [&'a JSONValue<'a>])
An array, as an arena slice of its elements in source order.
Object(&'a JSONHiddenClass<'a>, &'a [&'a JSONValue<'a>])
An object: the hidden class holding the sorted key names, plus the
values in the same order as JSONHiddenClass::keys.
Implementations§
Source§impl<'a> JSONValue<'a>
impl<'a> JSONValue<'a>
Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Returns Some(b) if this is a Boolean, else None.
Sourcepub fn as_string(&self) -> Option<AtomBytes>
pub fn as_string(&self) -> Option<AtomBytes>
Returns the interned handle (resolve bytes via the AtomTable).
Sourcepub fn as_array(&self) -> Option<ArrayView<'a>>
pub fn as_array(&self) -> Option<ArrayView<'a>>
Returns an ArrayView if this is an Array, else None.
Sourcepub fn as_object(&self) -> Option<ObjectView<'a>>
pub fn as_object(&self) -> Option<ObjectView<'a>>
Returns an ObjectView if this is an Object, else None.
Sourcepub fn emit_into(&self, emitter: &mut JSONEmitter<'_>, atoms: &AtomTable)
pub fn emit_into(&self, emitter: &mut JSONEmitter<'_>, atoms: &AtomTable)
Port of JSONValue::emitInto (JSONParser.cpp:39). atoms resolves
interned string handles to bytes. String handles store WTF-8 bytes
(surrogate-encoded astral chars / lone surrogates are valid), which are
decoded to UTF-16 for emission, matching C++ primitiveEmitString via
decodeUTF8<true> (surrogate-tolerant). Plain valid UTF-8 input also
works correctly via the same path.