Macro serde_json_lodash::flatten[][src]

macro_rules! flatten {
    () => { ... };
    ($a:expr $(,)*) => { ... };
    ($a:expr, $($rest:tt)*) => { ... };
}

Description can be found in lodash flatten

Examples:

#[macro_use] extern crate serde_json_lodash;
use serde_json::json;
assert_eq!(
  flatten!(json!([1, [2, [3, [4]], 5]])),
  json!([1, 2, [3, [4]], 5])
);

More examples:

assert_eq!(flatten!(), json!([]));
assert_eq!(flatten!(json!(null)), json!([]));
assert_eq!(flatten!(json!(false)), json!([]));
assert_eq!(flatten!(json!(0)), json!([]));
assert_eq!(flatten!(json!("")), json!([]));
assert_eq!(flatten!(json!("ab")), json!(["a","b"]));
assert_eq!(flatten!(json!("りしれ")), json!(["り","し","れ"]));
assert_eq!(flatten!(json!({})), json!([]));
assert_eq!(flatten!(json!({"a":1})), json!([]));
assert_eq!(flatten!(json!([null,false,0,"",[null,[false]],{"a":1}])), json!([null,false,0,"",null,[false],{"a":1}]));