use json_to_table::json_to_table;
use serde_json::json;
fn main() {
let value = json!(
[
{
"name": "Aleix Melon",
"id": "E00245",
"role": ["Dev", "DBA"],
"age": 23,
"doj": "11-12-2019",
"married": false,
"address": {
"street": "32, Laham St.",
"city": "Innsbruck",
"country": "Austria"
},
"referred-by": "E0012"
},
]
);
let table = json_to_table(&value).to_string();
println!("{}", table)
}
|
+-------------------------------------------------+
| +-------------+-------------------------------+ |
| | address | +---------+-----------------+ | |
| | | | city | Innsbruck | | |
| | | +---------+-----------------+ | |
| | | | country | Austria | | |
| | | +---------+-----------------+ | |
| | | | street | 32, Laham St. | | |
| | | +---------+-----------------+ | |
| +-------------+-------------------------------+ |
| | age | 23 | |
| +-------------+-------------------------------+ |
| | doj | 11-12-2019 | |
| +-------------+-------------------------------+ |
| | id | E00245 | |
| +-------------+-------------------------------+ |
| | married | false | |
| +-------------+-------------------------------+ |
| | name | Aleix Melon | |
| +-------------+-------------------------------+ |
| | referred-by | E0012 | |
| +-------------+-------------------------------+ |
| | role | +-------+ | |
| | | | Dev | | |
| | | +-------+ | |
| | | | DBA | | |
| | | +-------+ | |
| +-------------+-------------------------------+ |
+-------------------------------------------------+
|