最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

json - Using Jolt transform to use value of a key to locate another value in map - Stack Overflow

programmeradmin4浏览0评论

I need to use value of a field to lookup another value in map.

{
  "name": "Smith",
  "Occupation": {
    "Smith": "Engineer",
    "John": "Plumber",
    "Mary": "Doctor"
  }
}

output:

{
  "Name": "Smith",
  "Job": "Engineer"
}

how to do this using jolt?

I need to use value of a field to lookup another value in map.

{
  "name": "Smith",
  "Occupation": {
    "Smith": "Engineer",
    "John": "Plumber",
    "Mary": "Doctor"
  }
}

output:

{
  "Name": "Smith",
  "Job": "Engineer"
}

how to do this using jolt?

Share Improve this question edited Jan 17 at 16:16 Barbaros Özhan 65.4k11 gold badges36 silver badges61 bronze badges asked Jan 17 at 15:43 SunnydaysSunnydays 455 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You can use such a single shift transformation :

[
  {
    "operation": "shift",
    "spec": {
      "name": {
        "*": {
          "@(2,Occupation.&)": "Job"
        },
        "@": "&"//replicates "name" itself
      }
    }
  }
]

the demo on the site Jolt Transform Demo Using v0.1.1 is :

发布评论

评论列表(0)

  1. 暂无评论