Skip to main content

to_json_pretty

Function to_json_pretty 

Source
pub fn to_json_pretty(value: &LinoValue) -> String
Expand description

Encode a value as indented JSON, as JSON.stringify(value, null, 2) does.

The OpenAPI document is served this way, so that the document a JavaScript, a Python and a Rust service publish are the same bytes.

ยงExamples

use lino_rest_api::codec::to_json_pretty;
use lino_rest_api::value::{int, object};

assert_eq!(to_json_pretty(&object([("a", int(1))])), "{\n  \"a\": 1\n}");