我有一个简单的 json 文件,我正在尝试使用 jolt 对其进行转换并遇到问题,因为我对 jolt 还很陌生

I have a simple json file that I'm trying to transform using jolt and having trouble with it since I'm very new to jolt

这是我想要做的: 1. 将名字和姓氏与名字连接起来 2. 修改id为employeeID,加上员工ID前缀:emp_id 3. 如果 department 等于 sales,则 department 应该是 "SL" 4.如果department等于sales,那么department应该是"RET"

这是我的输入:

{
    "employees": [{
            "f_name": "tom",`
            "l_name": "smith",
            "id": "100",
            "department": "sales",
            "company": "ABC Intelligence"
        },

        {
            "f_name": "john",
            "l_name": "doe",
            "id": "102",
            "department": "returns",
            "company": "ABC Intelligence"
        }, {
            "f_name": "jane",
            "l_name": "doe",
            "id": "103",
            "department": "sales",
            "company": "ABC Intelligence"
        }
    ]
}

specs:
 [{
    "operation": "shift",
    "spec": {
        "employees": {
            "*": {

                "name": "=concat(@(1,f_name),' ',@(1,l_name))"


            }
        }
    }

},
 {
   "operation": "remove",
    "spec": {
      "employees": {
        "*": { 
          "f_name": "",
          "l_name": ""

      }
    }
  }
 }
]


desired output:

{
    "employees": [
        {
            "name": "tom smith",
            "employeeID": "emp_100",
            "department": "SL",
            "company": "ABC Intelligence"
        },
        {
            "name": "john doe",
            "employeeID": "emp_102",
            "department": "RET",
            "company": "ABC Intelligence"
        },
        {
            "name": "jane doe",
            "employeeID": "emp_103",
            "department": "SL",
            "company": "ABC Intelligence"
        }
    ]
}

我能够获得第一条规则,但仍在与其他规则作斗争。任何帮助将不胜感激

规格

[
  {
    "operation": "modify-default-beta",
    "spec": {
      // add the mapping of department name to code, so we can use it later
      "deptMap": {
        "sales": "SL",
        "returns": "RET"
      },
      "employees": {
        "*": {
          // build the fullName from the first and last names
          "name": "=concat(@(1,f_name),' ',@(1,l_name))",
          // build the employeeID
          "employeeID": "=concat(emp_,@(1,id))"
        }
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "employees": {
        "*": { // employees arrays
          // pass name, company, and employeeID thru
          "name": "employees[&1].name",
          "company": "employees[&1].company",
          "employeeID": "employees[&1].employeeID",
          // lookup the deparment code
          "department": {
            "*": { // value of dept
              // got up 5 levels, come back down the deptMap
              "@(4,deptMap.&)": "employees[&3].department"
            }
          }
        }
      }
    }
  }
]