pub fn jsonc_to_json_iter(jsonc: &str) -> JsonCToJsonIter<'_> 
Expand description

Non-allocating and zero-copy Iterator that yields string slices of valid JSON.

Warning: The conversion is infallible and does not validate jsonc. If it contains invalid JSON or invalid [JSON with Comments], then the invalid parts are included in the result, i.e. {foo,/*comment*/bar,} is turned into {foo,bar}.

See jsonc_to_json() for more information.

Example

let jsonc = r#"{foo}/**/[1,2,3,,]"bar""#;

let mut iter = jsonc_to_json_iter(jsonc);
assert_eq!(iter.next(), Some("{foo}")); // Line comment was removed
assert_eq!(iter.next(), Some("[1,2,3")); // Trailing commas was removed
assert_eq!(iter.next(), Some("]\"bar\""));
assert_eq!(iter.next(), None);