目前我有以下输入sson. 已添加"临时"-对象 在默认规范的帮助下.

{
  "items": [
    {
      "description": "myDescription",
      "attributes": [
        {
          "identifier": "colour",
          "type": "attribute",
          "values": [
            "DE"
          ],
          "hint": "1"
        },
        {
          "identifier": "pin",
          "type": "attribute",
          "values": [
            "4711"
          ],
          "hint": "1"
        },
        {
          "identifier": "price",
          "type": "price",
          "values": [
            "77.27"
          ],
          "hint": "1"
        },
        {
          "identifier": "weight",
          "type": "attribute",
          "values": [
            "0.47"
          ],
          "hint": "1"
        },
        {
          "identifier": "status",
          "type": "attribute",
          "values": [
            "active"
          ],
          "hint": "1"
        }
      ]
    }
  ],
  "temp": {
    "hint": "1",
    "identifier": "additionalDescription",
    "values": [
      {
        "lang": "de",
        "value": "temp"
      },
      {
        "lang": "en",
        "value": "temp"
      },
      {
        "lang": "fr",
        "value": "temp"
      },
      {
        "lang": "it",
        "value": "temp"
      },
      {
        "lang": "es",
        "value": "temp"
      }
    ],
    "type": "attribute"
  }
}

帖子主题:Re:Колибри

{
  "items": [
    {
      "description": "myDescription",
      "attributes": [
        {
          "identifier": "colour",
          "type": "attribute",
          "values": [
            "DE"
          ],
          "hint": "1"
        },
        {
          "identifier": "pin",
          "type": "attribute",
          "values": [
            "4711"
          ],
          "hint": "1"
        },
        {
          "identifier": "price",
          "type": "price",
          "values": [
            "77.27"
          ],
          "hint": "1"
        },
        {
          "identifier": "weight",
          "type": "attribute",
          "values": [
            "0.47"
          ],
          "hint": "1"
        },
        {
          "identifier": "status",
          "type": "attribute",
          "values": [
            "active"
          ],
          "hint": "1"
        },
        {
          "hint": "1",
          "identifier": "additionalDescription",
          "values": [
            {
              "lang": "de",
              "value": "myDescription"
            },
            {
              "lang": "en",
              "value": "myDescription"
            },
            {
              "lang": "fr",
              "value": "myDescription"
            },
            {
              "lang": "it",
              "value": "myDescription"
            },
            {
              "lang": "es",
              "value": "myDescription"
            }
          ],
          "type": "attribute"
        }
      ]
    }
  ]
}

我正在寻找的规格应该填满两个 要求:

  1. 将"新"对象集成到属性数组中.
  2. 用描述字段的值替换值"mat", 它可以在json的顶部找到.

不幸的是,我已经很难将数组正确地放入输出杨森中, 更不用说重写值"temp"


[
  {
    "operation": "shift",
    "spec": {
      "items": {
        "*": {
          "description": "&2.myDescription",
          "attributes": {
            "@(3,temp)": "&3.&2.&",
            "*": "&3.&2.&"
          }
        }
      }
    }
  }
]

我们非常感谢任何帮助.此外,我也很高兴收到有关第一个要求的提示.每当涉及数组时,我在构建RHS(右侧)时总是感到困难.

推荐答案

您需要的是在modify转换规范中从value属性级别开始穿越树4个级别后,引入所需的属性值以及overwrite选项,例如

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "temp": {
        "values": {
          "*": {
            "value": "@(4,items[0].description)"
          }
        }
      }
    }
  }
]

Json相关问答推荐

如何让jq输出长数据集?

JOLT转换过滤出特定值/对象

使用单元和非单元版本反序列化Rust中的枚举,而无需编写自定义反序列化程序

如何编写MongoDB查询以返回数组数组

NoneType 对象的 Python 类型错误

Rust实现:高效解析任意大小的JSON数组

在 NX 工作区中跨多个应用共享 ngx-translate 翻译文件

ETCD 导出为 json 并从 base64 解码所有键/值到人类可读

NiFi 使用嵌套数组将 avro 转换为 JSON 数组格式

父键中的 Perl JSON 数组

如何使用 jq 返回此 JSON 文件的文本字段?

JSON extract\set 的 SQLite JSON1 示例

按 JSON 数据类型 postgres 排序

如何通过 NSJSONSerialization 在 JSON 中包含空值?

将 Objective-C 对象序列化和反序列化为 JSON

在 Android 中使用带有 post 参数的 HttpClient 和 HttpPost

如何使用 Gson 解码具有未知字段的 JSON?

如何将单引号转义成双引号转成单引号

case 类只有一个字段时如何将json转为 case 类

为什么 RestTemplate 不将响应表示绑定到 PagedResources?