Function tracery::flatten_json[][src]

pub fn flatten_json<S: AsRef<str>>(s: S) -> Result<String>

Creates a new grammar from a JSON grammar string, then uses it to create a random output string, using the “origin” rule

Examples

let json = r##"{
    "origin": [ "#tool# is #description#!" ],
    "tool": [ "tracery" ],
    "description": [ "fun", "awesome" ]
}"##;

// Generate an output (either "tracery is fun!" or "tracery is awesome!")
let output = tracery::flatten_json(json)?;