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

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

I tried Simple Jolt transformation but its not working

问题

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

输入 :

  1. {
  2. "employer": [
  3. {
  4. "id": "98",
  5. "place_id": "7871",
  6. "name": "Iti-ha-cho"
  7. }
  8. ]
  9. }

期望输出 :

  1. {
  2. "id" : "98",
  3. "place_id" : "7871",
  4. "name" : "Iti-ha-cho"
  5. }

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

  1. {
  2. "operation": "shift",
  3. "spec": {
  4. "employer": {
  5. "id": "[&1].&",
  6. "place_id": "place_id",
  7. "name": "name"
  8. }
  9. }
  10. }
英文:

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

Input :

  1. {
  2. "employer": [
  3. {
  4. "id": "98",
  5. "place_id": "7871",
  6. "name": "Iti-ha-cho"
  7. }
  8. ]
  9. }

Expected Output :

  1. {
  2. "id" : "98",
  3. "place_id" : "7871",
  4. "name" : "Iti-ha-cho"
  5. }

Jolt Spec I tried but didnt work :

  1. {
  2. "operation": "shift",
  3. "spec": {
  4. "employer": {
  5. "id": "[&1].&",
  6. "place_id": "place_id",
  7. "name": "name"
  8. }
  9. }
  10. }

答案1

得分: 1

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

  1. [
  2. {
  3. "operation": "shift",
  4. "spec": {
  5. "employer": {
  6. "*": ""
  7. }
  8. }
  9. }
  10. ]

因为您只想提取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

  1. [
  2. {
  3. "operation": "shift",
  4. "spec": {
  5. "employer": {
  6. "*": ""
  7. }
  8. }
  9. }
  10. ]

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:

确定