0

如何过滤 jsonarray 以格式化 csv nodejs 我有数据 jsonArray 这种格式:

var data = [
    {
        "key": "key-001",
        "items": [
            {
                "date": "2022-01-13T09:00:00.000+07:00",
                "value": 9
            },
            {
                "date": "2022-01-13T09:01:00.000+07:00",
                "value": 11
            },
            {
                "date": "2022-01-13T09:02:00.000+07:00",
                "key": 2
            }
        ]
    },
    {
        "key": "key-002",
        "items": [
            {
                "date": "2022-01-13T09:00:00.000+07:00",
                "value": 1
            },
            {
                "date": "2022-01-13T09:02:00.000+07:00",
                "value": 2
            }
        ]
    }
];

我想将 jsonArray 数据过滤为 CSV 输出这种格式:

date, key-001, key-002
2022-01-13T09:00:00.000+07:00,9,1
2022-01-13T09:01:00.000+07:00,11,
2022-01-13T09:02:00.000+07:00,2,2

你有例子吗

4

0 回答 0