如何将 null 转换为空字符串?
How to transform null to empty string?
我需要将具有 null
值的 JSON 转换为空字符串,将 UNKNOWN 字符串转换为空字符串。
这是我的 JSON 长相。
{
"dmarId": 11536,
"salesForceRegion": "Unknown",
"industryVertical": null,
"modifiedDate": "2020-03-10T06:00:56"
},
{
"dmarId": 543,
"salesForceRegion": null,
"industryVertical": null,
"modifiedDate": "2020-03-10T06:00:56"
}
]
输出Json:
[
{
"dmarId": 11536,
"salesForceRegion": "",
"industryVertical": "",
"modifiedDate": "2020-03-10T06:00:56"
},
{
"dmarId": 543,
"salesForceRegion": "",
"industryVertical": "",
"modifiedDate": "2020-03-10T06:00:56"
}
]
我不知道如何创建规范来使用此配置。
这有效,
[
{
"operation": "shift",
"spec": {
"*": {
"dmarId": "[].dmarId",
"modifiedDate": "[&1].modifiedDate",
"salesForceRegion": {
"Unknown|null": {
"# ": "[&3].salesForceRegion"
}
},
"industryVertical": {
"Unknown|null": {
"# ": "[&3].industryVertical"
}
}
}
}
},
{
"operation": "modify-default-beta",
"spec": {
"*": {
"salesForceRegion": "",
"industryVertical": ""
}
}
}
]
我需要将具有 null
值的 JSON 转换为空字符串,将 UNKNOWN 字符串转换为空字符串。
这是我的 JSON 长相。
{
"dmarId": 11536,
"salesForceRegion": "Unknown",
"industryVertical": null,
"modifiedDate": "2020-03-10T06:00:56"
},
{
"dmarId": 543,
"salesForceRegion": null,
"industryVertical": null,
"modifiedDate": "2020-03-10T06:00:56"
}
]
输出Json:
[
{
"dmarId": 11536,
"salesForceRegion": "",
"industryVertical": "",
"modifiedDate": "2020-03-10T06:00:56"
},
{
"dmarId": 543,
"salesForceRegion": "",
"industryVertical": "",
"modifiedDate": "2020-03-10T06:00:56"
}
]
我不知道如何创建规范来使用此配置。
这有效,
[
{
"operation": "shift",
"spec": {
"*": {
"dmarId": "[].dmarId",
"modifiedDate": "[&1].modifiedDate",
"salesForceRegion": {
"Unknown|null": {
"# ": "[&3].salesForceRegion"
}
},
"industryVertical": {
"Unknown|null": {
"# ": "[&3].industryVertical"
}
}
}
}
},
{
"operation": "modify-default-beta",
"spec": {
"*": {
"salesForceRegion": "",
"industryVertical": ""
}
}
}
]