lsmem: Fix JSON output writing size as Number in bytes-mode
This commit is contained in:
@@ -578,7 +578,11 @@ fn print_json(lsmem: &Lsmem, opts: &Options) {
|
|||||||
for column in &opts.columns {
|
for column in &opts.columns {
|
||||||
record.insert(
|
record.insert(
|
||||||
column.get_name().to_lowercase(),
|
column.get_name().to_lowercase(),
|
||||||
serde_json::Value::String(row.get_value(column)),
|
if column == &Column::Size && opts.bytes {
|
||||||
|
serde_json::Value::Number(row.get_value(column).parse().unwrap())
|
||||||
|
} else {
|
||||||
|
serde_json::Value::String(row.get_value(column))
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
memory_records.push(serde_json::Value::Object(record));
|
memory_records.push(serde_json::Value::Object(record));
|
||||||
|
@@ -65,11 +65,10 @@ fn test_json_all() {
|
|||||||
sysroot_test_with_args("test_lsmem_json_all.expected", &["-J", "-a"]);
|
sysroot_test_with_args("test_lsmem_json_all.expected", &["-J", "-a"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FAILS, COMMENT FOR NOW - TODO
|
#[test]
|
||||||
// #[test]
|
fn test_json_bytes() {
|
||||||
// fn test_json_bytes() {
|
sysroot_test_with_args("test_lsmem_json_bytes.expected", &["-J", "-b"]);
|
||||||
// sysroot_test_with_args("test_lsmem_json_bytes.expected", &["-J", "-b"]);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_json_noheadings() {
|
fn test_json_noheadings() {
|
||||||
|
Reference in New Issue
Block a user