[−][src]Function edn_rs::json_to_edn
pub fn json_to_edn(json: String) -> String
json_to_edn
receives a json string and parses its common key-values to a regular EDN format.
tested examples are:
"{\"hello world\": \"julia\"}"
becomes"{:hello-world \"julia\"}"
"{\"hello\": null}"
becomes"{:hello nil}"
{\"hello\": 'c'}
becomes"{:hello \\c}"
"{\"multi_string with underscore\": 545643}"
becomes"{:multi-string-with-underscore 545643}"
use edn_rs::json_to_edn; fn emits_helloworld_edn() { let json = String::from("{\"hello\": \"world\"}"); let edn = String::from("{:hello \"world\"}"); assert_eq!(edn, json_to_edn(json)); } fn emits_vec_of_map_edn() { let json = String::from("[{\"hello\": \"world\"}, {\"hello\": \"julia\"}, {\"hello\": \"serde\"}"); let edn = String::from("[{:hello \"world\"} {:hello \"julia\"} {:hello \"serde\"}]"); assert_eq!(edn, json_to_edn(json)); }