Skip to main content

Module text_parse

Module text_parse 

Source
Expand description

The parse_json and parse_markdown walks behind two of those builtins, each gated by its own Cargo feature. See the module docs. Text-to-value parsers behind the parse_json and parse_markdown builtins in crate::builtin_fns::builtin_script_fns.

Both hand back a ScriptValue rather than a string, so a script indexes the result directly instead of parsing text itself; each host converts the result into its own value type the same way it converts any other builtin’s return. parse_json and parse_markdown are each behind their own Cargo feature (json, markdown) so a build that links no script host carries neither serde_json nor pulldown-cmark.

Functions§

parse_json
Parse src as JSON into a ScriptValue. An object becomes a ScriptValue::Map, an array a ScriptValue::Array, and a scalar keeps its JSON type. Malformed input yields ScriptValue::Unit.
parse_markdown
Parse src as markdown into a list of block records, one per heading, paragraph, code block, list item, and horizontal rule, in document order.
script_value_to_json
Write value as JSON text: the reverse of parse_json.