【发布时间】:2022-12-05 20:09:56
【问题描述】:
我需要使用嵌套有效负载将烤肉串转换为驼峰式。示例请求如下。
"is-success": true,
"response-date": "2019-02-20T11:42:11.963Z",
"result": {
"record-count": "abc123",
"bill-details-list": [
{
"source-system": "Abc123",
"bill-info": {
"bill-amount": "Abc123"
}
},
{
"SourceSystem": "abc123",
"bill-info": {
"bill-amount-po": "Abc123"
}
}
]
}
};
JSON 对象的深度最多可以有 5 个子元素。当我尝试从以下链接实施时 https://gist.github.com/sibu-github/a08c084ff64369f2f6a2b1ae6ee7f10d 输出不符合预期。 当前输出:
{
isSuccess: true,
responseDate: '2019-02-20T11:42:11.963Z',
result: { recordCount: 'abc123', 'billDetailsList': [ [Object], [Object] ] }
}
预期输出:
{
"isSuccess": true,
"responseDate": "2019-02-20T11:42:11.963Z",
"result": {
"recordCount": "abc123",
"billDetailsList": [
{
"sourceSystem": "Abc123",
"billInfo": {
"billAmountPo": "Abc123"
}
},
{
"sourceSystem": "abc123",
"billInfo": {
"billAmountPo": "Abc123"
}
}
]
}
};
你能提供你的意见吗?
【问题讨论】:
标签: javascript json camelcasing kebab-case