在 Cloud BigQuery 中,接受的 JSON 格式为:
一个 JSON 对象,包括任何嵌套/重复的字段,必须出现在每一行上。
参考:https ://cloud.google.com/bigquery/data-formats#json_format
现在,给定一个json:
{
"1": {
"kind": "person",
"fullName": "John Doe",
"age": 22,
"gender": "Male",
"citiesLived": [
{
"place": "Seattle",
"numberOfYears": 5
},
{
"place": "Stockholm",
"numberOfYears": 6
}
]
},
"2": {
"kind": "person",
"fullName": "Jane Austen",
"age": 24,
"gender": "Female",
"citiesLived": [
{
"place": "Los Angeles",
"numberOfYears": 2
},
{
"place": "Tokyo",
"numberOfYears": 2
}
]
}
}
如何将其转换为以下 by jq
?
{"kind": "person", "fullName": "John Doe", "age": 22, "gender": "Male", "citiesLived": [{ "place": "Seattle", "numberOfYears": 5}, {"place": "Stockholm", "numberOfYears": 6}]}
{"kind": "person", "fullName": "Jane Austen", "age": 24, "gender": "Female", "citiesLived": [{"place": "Los Angeles", "numberOfYears": 2}, {"place": "Tokyo", "numberOfYears": 2}]}