jsonerr2array

Crates.iojsonerr2array
lib.rsjsonerr2array
version0.0.2
sourcesrc
created_at2023-06-18 19:17:07.702703
updated_at2023-06-19 07:08:48.964446
descriptionjsonerr to array
homepagehttps://codeberg.org/AlbanMinassian/errorjson
repositoryhttps://codeberg.org/AlbanMinassian/errorjson
max_upload_size
id893601
size12,303
Alban Minassian (AlbanMinassian)

documentation

https://docs.rs/jsonerr2array

README

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
Commit count: 0

cargo fmt