Crate jsonerr2array

source ·
Expand description

README

crates.io docs.rs github

jsonerr2array help to transform jsonerr to array json

Usage

use jsonerr2array::*;
fn main() {
    let result = jsonerr2array(&serde_json::json!({
        "meta": {},
        "iserr": true,
        "err": {
            "code": "ERR001",
            "message": "message",
            "payload": { "payload" : 1 },
            "origin": {
                "meta": {},
                "iserr": true,
                "err": {
                    "code": "ERR002",
                    "message": "message",
                    "payload": { "payload" : 2 }
                }
            }
        }
    }));
    println!("{:#?}", myjson);
}

return

[
    {
        "meta": {},
        "iserr": true,
        "err": {
            "code": "ERR001",
            "message": "message",
            "payload": { "payload" : 1 }
        }
    },
    {
        "meta": {},
        "iserr": true,
        "err": {
            "code": "ERR002",
            "message": "message",
            "payload": { "payload" : 2 }
        }
    }
]

Examples

  • cargo run --example basic

Functions