Skip to main content

to_json

Function to_json 

Source
pub fn to_json(document: &DesignFile) -> Result<String, FormatError>
Expand description

The canonical JSON text of document: two-space indents, keys in declared order, a final newline.

§Errors

FormatError::Invalid for a document of another version, which this crate doesn’t write; FormatError::NotRepresentable when the text would not read back as document, including when from_json would refuse it (a rule of SourceFile): every document written is read again and compared, so a value JSON cannot carry (a number that is not finite) is refused here rather than lost.