Json List/Array 个案例中的 JOLT TRANSFORM
JOLT TRANSFORM in Json List/Array cases
我正在尝试进行 JOLT 转换,但在为其编写规范时遇到了一些困难。我想将一些 json 元素从一个列表移动到另一个列表。
INPUT JSON
{
"billingsystem": {
"request": {
"profile": {
"identification_details": [
{
"identification_type": "1",
"identification_number": "4321221",
"id_issue_date": "11/11/2014",
"id_expiry_date": "11/11/2040",
"issuer_id": "vx",
"comment": "other"
}
],
"addresses": [
{
"language_id": "1",
"subscriber_level": "0",
"address_type": "0",
"addr_line1": "13 B, Sea View",
"addr_line2": "3rd Cross",
"addr_line3": "Chicago",
"addr_line4": "Illinois",
"addr_line5": "60601",
"country_id": "1"
}
]
}
}
}
}
我想将其更改为给定输出 json。我需要一个可以解决问题的规范。需要一个规范来处理
OUTPUT JSON
{
"billingsystem": {
"request": {
"profile": {
"identification_details": [
{
"identification_type": "1",
"identification_number": "4321221",
"id_issue_date": "11/11/2014",
"id_expiry_date": "11/11/2040",
"issuer_id": "vx",
"comment": "other",
"addr_line3": "Chicago",
"addr_line4": "Illinois",
"addr_line5": "60601",
"country_id": "1"
}
],
"addresses": [
{
"language_id": "1",
"subscriber_level": "0",
"address_type": "0",
"addr_line1": "13 B, Sea View",
"addr_line2": "3rd Cross",
}
]
}
}
}
}
当你使用数组(颠簸)索引时,最重要的是你想将参数从哪里转移到哪里,并且还知道“@,*,(索引)”这将帮助你从那里
解决方案 - 规格:
[
{
"operation": "shift",
"spec": {
"billingsystem": {
"request": {
"profile": {
"addresses": {
"*": {
"language_id": "request.profile.addresses[&1].language_id",
"subscriber_level": "request.profile.addresses[&1].subscriber_level",
"address_type": "request.profile.addresses[&1].address_type",
"addr_line1": "request.profile.addresses[&1].addr_line1",
"addr_line2": "request.profile.addresses[&1].addr_line2"
}
},
"identification_details": {
"*": {
"identification_type": "request.profile.identification_details[&1].identification_type",
"identification_number": "request.profile.identification_details[&1].identification_number",
"id_issue_date": "request.profile.identification_details[&1].id_issue_date",
"id_expiry_date": "request.profile.identification_details[&1].id_issue_date",
"issuer_id": "request.profile.identification_details[&1].id_expiry_date",
"comment": "request.profile.identification_details[&1].comment",
"@(2,addresses[&].addr_line3)": "request.profile.identification_details[&1].addr_line3",
"@(2,addresses[&].addr_line4)": "request.profile.identification_details[&1].addr_line4",
"@(2,addresses[&].addr_line5)": "request.profile.identification_details[&1].addr_line5"
}
}
}
}
}
}
}
]
我正在尝试进行 JOLT 转换,但在为其编写规范时遇到了一些困难。我想将一些 json 元素从一个列表移动到另一个列表。
INPUT JSON
{
"billingsystem": {
"request": {
"profile": {
"identification_details": [
{
"identification_type": "1",
"identification_number": "4321221",
"id_issue_date": "11/11/2014",
"id_expiry_date": "11/11/2040",
"issuer_id": "vx",
"comment": "other"
}
],
"addresses": [
{
"language_id": "1",
"subscriber_level": "0",
"address_type": "0",
"addr_line1": "13 B, Sea View",
"addr_line2": "3rd Cross",
"addr_line3": "Chicago",
"addr_line4": "Illinois",
"addr_line5": "60601",
"country_id": "1"
}
]
}
}
}
}
我想将其更改为给定输出 json。我需要一个可以解决问题的规范。需要一个规范来处理
OUTPUT JSON
{
"billingsystem": {
"request": {
"profile": {
"identification_details": [
{
"identification_type": "1",
"identification_number": "4321221",
"id_issue_date": "11/11/2014",
"id_expiry_date": "11/11/2040",
"issuer_id": "vx",
"comment": "other",
"addr_line3": "Chicago",
"addr_line4": "Illinois",
"addr_line5": "60601",
"country_id": "1"
}
],
"addresses": [
{
"language_id": "1",
"subscriber_level": "0",
"address_type": "0",
"addr_line1": "13 B, Sea View",
"addr_line2": "3rd Cross",
}
]
}
}
}
}
当你使用数组(颠簸)索引时,最重要的是你想将参数从哪里转移到哪里,并且还知道“@,*,(索引)”这将帮助你从那里
解决方案 - 规格:
[
{
"operation": "shift",
"spec": {
"billingsystem": {
"request": {
"profile": {
"addresses": {
"*": {
"language_id": "request.profile.addresses[&1].language_id",
"subscriber_level": "request.profile.addresses[&1].subscriber_level",
"address_type": "request.profile.addresses[&1].address_type",
"addr_line1": "request.profile.addresses[&1].addr_line1",
"addr_line2": "request.profile.addresses[&1].addr_line2"
}
},
"identification_details": {
"*": {
"identification_type": "request.profile.identification_details[&1].identification_type",
"identification_number": "request.profile.identification_details[&1].identification_number",
"id_issue_date": "request.profile.identification_details[&1].id_issue_date",
"id_expiry_date": "request.profile.identification_details[&1].id_issue_date",
"issuer_id": "request.profile.identification_details[&1].id_expiry_date",
"comment": "request.profile.identification_details[&1].comment",
"@(2,addresses[&].addr_line3)": "request.profile.identification_details[&1].addr_line3",
"@(2,addresses[&].addr_line4)": "request.profile.identification_details[&1].addr_line4",
"@(2,addresses[&].addr_line5)": "request.profile.identification_details[&1].addr_line5"
}
}
}
}
}
}
}
]