pub unsafe fn to_object_iter_unchecked<'de, I: JsonInput<'de>>(
json: I,
) -> ObjectJsonIter<'de> ⓘ
Expand description
Traverse the JSON text through a lazy object iterator. The JSON parsing will doing when iterating.
The item of the iterator is a key-value pair: (FastStr,
Result<LazyValue>
).
§Errors
If the JSON is empty, or not a object, the result will be Err and the next()
will return
None
.
§Safety
If the json is invalid, the result is undefined.
§Examples
use faststr::FastStr;
use sonic_rs::JsonValueTrait;
let json = FastStr::from(r#"{"a": null, "b":[1, 2, 3]}"#);
for ret in unsafe { to_object_iter_unchecked(&json) } {
assert!(ret.is_ok());
let (k, v) = ret.unwrap();
if k == "a" {
assert!(v.is_null());
} else if k == "b" {
assert_eq!(v.as_raw_str(), "[1, 2, 3]");
}
}