使用jq等基本工具将JSON转换为CSV
我需要将以下JSON转换为CSV。以下代码需要从JSON转换为CSV。我必须再写几行,否则Stack不会让我发布这个使用jq等基本工具将JSON转换为CSV,json,regex,csv,jq,Json,Regex,Csv,Jq,我需要将以下JSON转换为CSV。以下代码需要从JSON转换为CSV。我必须再写几行,否则Stack不会让我发布这个 { "took": 21, "timed_out": false, "_shards": { "total": 6, "successful": 6, "skipped": 0, "failed":
{
"took": 21,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 6,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0.18232156,
"hits": [
{
"_index": "raw-log-2020-09-18",
"_type": "raw-log-mapping",
"_id": "jdghjdshgjdfhgdg",
"_score": 0.18232156,
"fields": {
"dynamicAddressFlag": [
"1"
],
"chargingCharacteristics": [
"8000"
],
"recordSequenceNumber": [
"1000"
],
"listOfServiceData_servingNodeAddress": [
"1.2.3.7"
],
"pGWPLMNIdentifier": [
"87sdf7"
],
"chargingID": [
"769887"
],
"listOfServiceData_resultCode": [
"1"
],
"localSequenceNumber": [
"1000"
],
"listOfServiceData_qoSInformationNeg": [
"9"
],
"listOfServiceData_pSFurnishChargingInfo": [
"00"
],
"served3gpp2MEID": [
"11"
],
"servedPDPAddress": [
"17.2.3.6"
],
"listOfServiceData_localSequenceNumber": [
"0"
],
"GSNAddress_iPBinV4Address": [
"11.11.11.11"
],
"listOfServiceData_serviceSpecificInfo": [
"11"
],
"nodeID": [
"xc-spgwxx-xx-xx-xx"
],
"camelchanrgingInformation": [
"11"
],
"pDNConnectionChargingID": [
"1"
],
"listOfServiceData_3GPP2UserLocationInformation": [
"11"
],
"listOfServiceData_timeOfLastUsage": [
"2020-09-18 12:04:06"
],
"userCSGInformation": [
"00000001"
],
"servingNodeAddress": [
"11.11.22.22"
],
"CallDuration": [
"10"
],
"pSFurnishChargingInform": [
"00"
],
"listOfServiceData_datavolumeFBCUplink": [
"1000"
],
"listOfServiceData_serviceIdentifier": [
"0"
],
"listOfServiceData_timeOfReport": [
"2020-09-18 12:00:05"
],
"listOfServiceData_userLocationInformation": [
"00"
],
"listOfServiceData_timeOfFirstUsage": [
"2020-09-18 12:00:05"
],
"mSTimeZone": [
"0000"
],
"listOfServiceData_datavolumeFBCDownlink": [
"1001"
],
"listOfServiceData_failureHandlingContinue": [
"0"
],
"MSISDN": [
"7636637833"
],
"rATType": [
"6"
],
"listOfServiceData_eventBasedCharge": [
"0"
],
"listOfServiceData_ratingGroup": [
"9000"
],
"PLMNId": [
"44f050"
],
"chChSelectionMode": [
"3"
],
"apnSelectionMode": [
"0"
],
"accessPointNameNI": [
"bizflat4g.softbank"
],
"userLocationInformation": [
"1844f050112244f05011223344"
],
"RecordType": [
"85"
],
"IMSI": [
"440000000000003"
],
"DataType": [
"RAW"
],
"startTime": [
"2020-03-18 03:04:05"
],
"stopTime": [
"2020-03-18 03:04:06"
],
"iMSsignalingContext": [
"NULL"
],
"listOfServiceData_timeUsage": [
"100"
],
"servedMNAI": [
"0"
],
"listOfServiceData_chargingRuleBaseName": [
"1"
],
"listOfServiceData_aFRecordInformation": [
"11"
],
"listOfServiceData_timeQuotaMechanism": [
"0"
],
"pdpType": [
"f121"
],
"ServingNodeType": [
"1"
],
"IMEI": [
"1122334455667798"
],
"causeForRecClosing": [
"17"
],
"listOfServiceData_serviceConditionChange": [
"00000000c0"
]
}
},
{
"_index": "raw-log-2020-09-18",
"_type": "raw-log-mapping",
"_id": "iv7gTXUBgs5mDzdfvBkD",
"_score": 0.18232156,
"fields": {
"chargingCharacteristics": [
"8000"
],
"MSISDN": [
"55476576575"
],
"listOfServiceData_servingNodeAddress": [
"1.2.3.7"
],
"chargingID": [
"1234"
],
"rATType": [
"6"
],
"listOfServiceData_ratingGroup": [
"6200"
],
"localSequenceNumber": [
"8456456458"
],
"accessPointNameNI": [
"m2666.js"
],
"RecordType": [
"85"
],
"servedPDPAddress": [
"1.22.3.6"
],
"GSNAddress_iPBinV4Address": [
"1.22.3.4"
],
"IMSI": [
"454545652"
],
"DataType": [
"RAW"
],
"listOfServiceData_timeUsage": [
"100"
],
"pdpType": [
"f121"
],
"ServingNodeType": [
"1"
],
"listOfServiceData_timeOfLastUsage": [
"2020-09-18 12:04:06"
],
"IMEI": [
"12345456454545451"
],
"causeForRecClosing": [
"17"
],
"listOfServiceData_serviceConditionChange": [
"0000000000"
],
"servingNodeAddress": [
"1.18.3.5"
],
"CallDuration": [
"10"
],
"listOfServiceData_datavolumeFBCUplink": [
"1000"
],
"listOfServiceData_timeOfReport": [
"2020-09-18 12:00:05"
],
"listOfServiceData_timeOfFirstUsage": [
"2020-09-18 12:00:05"
],
"listOfServiceData_datavolumeFBCDownlink": [
"1001"
]
}
}
]
}
}
只有jq和pyhton可用于转换。
如果绝对必要,我将在另一台机器上使用miller