javascript - 将 JsonArray 转换为 JsonObject Jquery
问题描述
我想将 JsonArray 转换为 JSON 对象,从这里:
[{
"departmentID":"baccf1ba-d9ca-4480-46cd-08d7e5f27472",
"criteria":"absensi",
"weight":21,
"status":true
}]
对此:
{
"departmentID":"baccf1ba-d9ca-4480-46cd-08d7e5f27472",
"criteria":"absensi",
"weight":21,
"status":true
}
解决方案
const truc =
[ { departmentID: "baccf1ba-d9ca-4480-46cd-08d7e5f27472"
, criteria: "absensi"
, weight: 21
, status: true
} ]
const bidule = {...truc[0]}
console.log(bidule)
推荐阅读
- reactjs - 在material-ui的主题配置中直接支持渐变
- android - 如何在列表 Android 中动态显示 lat long 的屏幕截图?
- angular6 - Angular 6 无法编译并出现服务错误
- java - 比较不同文件(CSV、Excel)中两列的日期 Java Apache commons 和 poi 以了解日期的相似之处
- php - 成功后如何在ajax中调用php函数
- r - 计算解释变量之间的相关性
- dojo - Dojo ValidationTextBox 在 Enter 上显示 missingMessage
- algorithm - 六边形网格顶点的极坐标?
- android - RecyclerView onMeasure 性能问题
- openthread - 如何使用C语言在Windows 10上的两个模拟openthread之间传递消息