如何在颠簸中创建特定数组

how to create specific array in jolt

我正在学习 jolt,但很难掌握,因为有数组,输出必须与下面的示例完全相同。

如何创建震动规格表, json 输入是这样的 :

[
  {
    "encounter_date": "1616509603296",
    "id_no": "671223025051",
    "patient_id": "MAEPS-PID-2100003716",
    "patient_mrn": "MAEPS-MRN-2100003815",
    "first_name": "MOHD RAZALI "
  },
  {
    "encounter_date": "1621324591194",
    "id_no": "950224145647",
    "patient_id": "MAEPS-PID-2100030302",
    "patient_mrn": "MAEPS-MRN-2100030401",
    "first_name": "MUHAMMAD FADDIL BIN YASIN"
  }
]

预期的输出是这样的:

{
  "forms": [
    {
      "visit": {
        "patientId": "MAEPS-PID-2100003716",
        "Patientmrn": "MAEPS-MRN-2100003815",
        "encounterDate": "2021-03-23 22:26:43.296"
      },
      "person": {
        "firstname": "MOHD RAZALI ",
        "identifications": [
          {
            "idNo": "671223025051"
          }
        ]
      }
    },
    {
      "visit": {
        "patientId": "MAEPS-PID-2100030302",
        "Patientmrn": "MAEPS-MRN-2100030401",
        "encounterDate": "2021-05-18 15:56:31.194"
      },
      "person": {
        "firstname": "MUHAMMAD FADDIL BIN YASIN",
        "identifications": [
          {
            "idNo": "950224145647"
          }
        ]
      }
    }
  ]
}

我是新手,需要指导

这只需一个 shift 操作即可完成,如下所示。

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "patient_id": "forms[&1].visit.patientId",
        "patient_mrn": "forms[&1].visit.Patientmrn",
        "encounter_date": "forms[&1].visit.encounterDate",
        "first_name": "forms[&1].person.firstname",
        "id_no": "forms[&1].person.identifications[0].idNo"
      }
    }
  }
]