简体   繁体   中英

JOLT Shift transformation

Need JOLT spec for JSON input and output.PFB the data for same.

Input :

{
  "customer": {
    "contact": {
      "name": {
        "firstName": "Karan",
        "lastName": "Singh",
        "middleName": null
      },
      "phone": "902-167-5435",
      "secondaryPhone": null,
      "email": "Karan.Singh@gmail.com"
    }
  }
}

Expected Output :

{
  "buyerInfo": {
    "id": "as123-e617-4410-969f",
    "primaryContact": {
      "name": {
        "firstName": "Karan",
        "lastName": "Singh"
      },
      "phone": {
        "completeNumber": "9021675435"
      },
      "email": {
        "emailAddress": "Karan.Singh@gmail.com"
      }
    }
  }
}

Please help me out on providing the JOLT spec for same. Also please share JOLT links.

[
  {
    "operation": "shift",
    "spec": {
      "customer": {
        "contact": {
          "name": {
            "firstName": "buyerInfo.primaryContact.name.firstName",
            "lastName": "buyerInfo.primaryContact.name.lastName"
          },
          "phone": "buyerInfo.primaryContact.phone.completeNumber",
          "email": "buyerInfo.primaryContact.email.emailAddress"
        }
      }
    }
  }
]

Got the JOLT Spec :)

Think symbolically, write less through use of some wildcards such as * , & and # as in the following spec

[
  {
    "operation": "shift",
    "spec": {
      "#as123-e617-4410-969f": "buyerInfo.id",
      "cu*": {
        "co*": {
          "name": {
            "*t*ame": "buyerInfo.primary&(2,0).&1.&"
          },
          "ph*": "buyerInfo.primarycontact.&.completeNumber",
          "em*": "buyerInfo.primarycontact.&.&Address"
        }
      }
    }
  }
]

The demo on the site http://jolt-demo.appspot.com/ is

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM