我尝试了简单的 Jolt 转换,但它不起作用。

huangapple go评论63阅读模式
英文:

I tried Simple Jolt transformation but its not working

问题

抱歉,你提供的内容中包含HTML实体编码(如")和特殊字符,无法直接进行翻译。以下是经过翻译的内容,但仍包含HTML实体编码。如果需要去掉HTML实体编码,你可以在翻译后自行处理:

输入 :

{
  "employer": [
    {
      "id": "98",
      "place_id": "7871",
      "name": "Iti-ha-cho"
    }
  ]
}

期望输出 :

{
  "id" : "98",
  "place_id" : "7871",
  "name" : "Iti-ha-cho"
}

Jolt规范 我尝试了但没有成功 :

{
  "operation": "shift",
  "spec": {
    "employer": {
      "id": "[&1].&",
      "place_id": "place_id",
      "name": "name"
    }
  }
}
英文:

I want to convert this data using jolt, I tried but it showing null as result

Input :

{
  "employer": [
    {
      "id": "98",
      "place_id": "7871",
      "name": "Iti-ha-cho"
    }
  ]
}

Expected Output :

{
  "id" : "98",
  "place_id" : "7871",
  "name" : "Iti-ha-cho"
}

Jolt Spec I tried but didnt work :

{
  "operation": "shift",
  "spec": {
    "employer": {
      "id": "[&1].&",
      "place_id": "place_id",
      "name": "name"
    }
  }
}

答案1

得分: 1

当前问题是由于缺少方括号嵌套规范引起的,您不需要指定那些冗长的内容,只需要以下规范即可:

[
  {
    "operation": "shift",
    "spec": {
      "employer": {
        "*": ""
      }
    }
  }
]

因为您只想提取employer数组的子内容。

英文:

While the current issue is due to missing square bracket nesting the spec, you don't need to specify those long stuff, just the following spec will suffice

[
  {
    "operation": "shift",
    "spec": {
      "employer": {
        "*": ""
      }
    }
  }
]

as you only want to extract the sub-content of the employer array.

huangapple
  • 本文由 发表于 2023年6月1日 21:36:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76382472.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定