jquery - 根据名称转换 JSON 的输出
问题描述
输入是从卡中提取的数据。发现很难提取,尤其是因为0.jpg是根据图像名称动态生成的
.doc.0.jpg 变得无效,因此无法获取 0.jpg 以下的值
"doc": {
"0.jpg": {
"cNumber": "6218961 450 3875",
"cNames": " 1 VEN NUT 2 SIRKA SARTH",
"cExpiry": "09/2025"
},
"number": {
"nTotal": 3,
"nRequires": 3,
"nDocuments": 1
}
}
我应该能够根据 cNames 中的数字提取名称
输出应该是
"doc": {
"0.jpg": {
"cNumber": "6218961 450 3875",
"cNames": [ "VEN NUT",
"SIRKA SARTH"],
"cExpiry": "09/2025"
},
"number": {
"nTotal": 3,
"nRequires": 3,
"nDocuments": 1
}
}
解决方案
.doc |= map_values(if has("cNames")
then .cNames |= [splits(" *[0-9]+ *")][1:]
else . end)
推荐阅读
- c++ - std::forward_list emplace_after O(1) 怎么样?
- reactjs - 我的 useEffect() 有什么问题?它返回空对象
- amazon-web-services - AWS Step Functions 图形导出 API
- javascript - 加载 gif 然后过渡到 reactjs 上的网页
- reactjs - 为什么在部署 React 项目时终端命令 'git add .'、git commit...' 和 'git push...' 列为可选?
- c# - 学习 C#,我有一个选角问题
- python - 如何在 for 循环中制作视频捕获流以传输多个摄像机
- apache - Apache 2.4:是否可以独立于父目录身份验证对子目录进行身份验证?
- c# - AddSigningCredentials 错误指示未定义对象但堆栈跟踪中没有项目代码
- flutter - TextField 键盘上的颤振手柄返回(关闭)按钮