javascript - 如何合并两个 JSON,其中一个 JSON 将具有实际响应,另一个将提供配置
问题描述
我有actual Response
如下:
{
"ClassifierId": "abc1",
"results": [{
"Input": "Input data1",
"Score": 0.9,
"Prediction": "Prediction1"
},
{
"Input": "Input data2",
"Score": 0.1,
"Prediction": "Prediction1"
}
]
}
并且需要config-json
如下绑定:
[{
"type": "",
"row": [{
"header": "",
"col": [{
"data": [{
"label": "Score",
"valueMapping": "@^results[i].Score",
"displayType": "vertical"
},
{
"label": "Prediction",
"valueMapping": "@^results[i].Prediction",
"displayType": "vertical"
}
]
}]
},
{
"header": "",
"col": [{
"data": [{
"label": "Text",
"valueMapping": "@^results[i].Input",
"displayType": "vertical"
}]
}]
}
]
}]
我的实际响应可能与 api 响应不同,但我只需要配置配置 JSON。'"@^results[i].***"' 是来自实际 JSON 的相应值。'@^' 用于标识映射值。
我尝试了几种方法,但不幸的是没有运气,请指导/指导/帮助
解决方案
推荐阅读
- javascript - 在 React 功能组件中多次调用函数
- google-cloud-platform - 在 GCP 自定义图表中使用实例名称而不是实例 ID
- python - Python,子级无法从父级继承函数
- python - 为什么我的 sklearn 自定义转换器在 ColumnTransformer 中使用时不保存属性?
- c - 49个线程的线程屏障
- google-cloud-platform - 我如何搜索用户以外的内容?
- javascript - 如何复制 reddit 的帖子视图,其中单击帖子以模式打开并更改 URL 或通过直接访问 URL 在整页中打开?
- python - 使用 Python/Pandas 创建包含多张工作表的 Excel 文件
- reactjs - reactjs如何显示图表
- c# - 用于 wpf 应用程序的 Visual c++ 本地部署(cef sharp 需要)