Skip to content

Commit

Permalink
Process json arrays in jsonl command
Browse files Browse the repository at this point in the history
and embed it as a string
  • Loading branch information
jqnatividad committed Dec 23, 2021
1 parent ffc89e0 commit e810108
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cmd/jsonl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ fn recurse_to_infer_headers(value: &Value, headers: &mut Vec<Vec<String>>, path:
Value::Object(map) => {
for (key, value) in map.iter() {
match value {
Value::Null | Value::Bool(_) | Value::Number(_) | Value::String(_) => {
Value::Null
| Value::Bool(_)
| Value::Number(_)
| Value::String(_)
| Value::Array(_) => {
let mut full_path = path.clone();
full_path.push(key.to_string());

Expand Down Expand Up @@ -103,6 +107,11 @@ fn json_line_to_csv_record(value: &Value, headers: &Vec<Vec<String>>) -> csv::St
}
Value::Number(v) => v.to_string(),
Value::String(v) => v,
Value::Array(v) => v
.iter()
.map(|x| x.to_string())
.collect::<Vec<_>>()
.join(","),
_ => String::new(),
});
} else {
Expand Down

0 comments on commit e810108

Please sign in to comment.