Replacing specific array item
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- json, powershell
- 领域
- tooling
调研方向
从 Replace wiki page 开始,针对提供的 JSON 复现 Sample transform 1,然后将其与可正常工作的 root-level transform 进行比较。跟踪相对于 array 的 @jdt.path 是如何被解析和应用的;当 Foo 项的 Value 发生变化且不依赖其序数位置时,即完成。
由索引模型根据 Issue 内容生成。
描述
I am having trouble replacing specific array items using the @jdt.path syntax as described on the "Replace" wiki page. The @jdt verbs and attributes don't parse or transform when placed under the array object itself. I was able to get this working by moving the @jdt.replace to the top of the object and then drilling down. Is this a bug?
Sample JSON:
{
"MyStuff": [
{
"Name": "Foo",
"Value": 123
},
{
"Name": "Bar",
"Value": 456
}
]
}
The goal is to change the value of the "Foo" item without knowing the ordinal position or how many objects are in the MyStuff array.
Sample transform 1:
{
"MyStuff": {
"@jdt.replace": {
"@jdt.path": "@[?(@.Name == 'Foo')].Value",
"@jdt.value": 456
}
}
}
This should work according to the documentation but all I get is the MyStuff node literally replaced with the transform syntax.
Sample transform 2:
{
"@jdt.replace": {
"@jdt.path": "$.MyStuff[?(@.Name == 'Foo')].Value",
"@jdt.value": 456
}
}
Alternately, if we place the @jdt.replace at the root and change @jdt.path to start from the root and navigate into MyStuff, it works as expected.
I'm using Visual Studio 2022 + SlowCheetah 4.0.50 in a .NET Framework 4.7.2 project.
- 主要语言
- PowerShell
- 星标
- 117
- 派生
- 38
- 平均合并
- 5 天 52 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/json-document-transforms 的其他 Issue
-
难度 5/5 一周以上 新手友好度 15/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
难度 2/5 1-3 小时 新手友好度 52/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
Release request未关闭
难度 3/5 1-2 天 新手友好度 25/100
microsoft/json-document-transforms#27 · 1 个 reaction ·
查看 microsoft/json-document-transforms 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
area:holodeck review-finding
难度 2/5 1-3 小时 新手友好度 67/100
hyperdrive-technology/holodeck#196 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
cofade/open-garden-planner#516 ·
维护者通常 1 天内回复
-
freshness freshness:verdict-moving
难度 2/5 1-3 小时 新手友好度 70/100
thoroc/context-radar#279 ·