jsonata - 使用 Transform 运算符从对象中删除一个或多个键/值对?
问题描述
JSONata 新手签到。我已经查看了这个论坛中的所有问题,但找不到答案,所以在这里问。
鉴于此来源...
{
"Price": 34.45,
"Product Name": "Bowler Hat",
"ProductID": 858383,
"Quantity": 2,
"SKU": "0406654608"
}
我想减少到...
{
"Product Name": "Bowler Hat",
"ProductID": 858383,
"SKU": "0406654608"
}
...使用Transform运算符删除价格和数量。我已经尝试过这个的各种排列...
$ ~> |*|{}, ['Price', 'Quantity']|
..但没有得到我正在寻找的结果。这是一个锻炼者链接。
提前感谢您的任何帮助。
解决方案
Just a small modification needed - the 'matching' clause needs to match the object that you wish to modify, in your case it is the context item '$'. The wildcard '*' is going to return the sequence of values in that object rather than the object itself. So your expression should be:
$ ~> |$|{}, ['Price', 'Quantity']|
推荐阅读
- android - 扑朔迷离的 Firebase 用户
- c# - 转换矩阵
去污点 - machine-learning - 无人机着陆地点数据集
- c++ - 当 QProcess 需要用户使用 Qt 输入时如何阅读
- c - 具有多个定义的嵌入式 C 和 AVR GCC 编译问题
- django - Superset Flask OAuth 客户端没有 redirect_uri
- php - 如何通过laravel中的group by子句对获取的数据实现循环?
- javascript - Javascript/Firestore: Uncaught (in promise) TypeError: firebase.firestore(...).collection(...).doc(...).collection(...).set is not a function
- python - pytest_bdd.exceptions.StepDefinitionNotFoundError 在 StepDefinition 中使用 parrs.re 时触发错误
- angular - 我应该订阅还是使用支持属性来更新组件中的依赖数据?