检查 jolt 中是否为 null 或 empty 并放入输入 JSON 中存在的另一个值
Check if null or empty in jolt and put another value which is present in input JSON
这是我的输入JSON:
{
"AddressBilling": {
"FirstName": "Some Name",
"LastName": "Some Name",
"Address":"some address"
}
"AddressShipping": {
"FirstName": "",
"LastName": "",
"Address":""
}
}
我想保留 "AddressBilling" 和 "AddressShipping" 但名称不同 i:e "payment_address" 和 "shipping_address",我为此编写了一个规范文件payment_address”部分
{
"operation": "shift",
"spec": {
"AddressBilling": {
"FirstName": "payment_address.firstname",
"LastName": "payment_address.lastname",
"Address": "payment_address.address"
},
"AddressShipping": {
"FirstName": "shipping_address.firstname",
"LastName": "shipping_address.lastname"
}
}
}
现在我想要的是检查 "AddressShipping" 对象中的 "Address" 键是否为 null 然后我想将 "AddressBilling" 的 "Address" 复制到 "Address" "shipping_address".
可以用 "modify-default" 做到这一点。 Modify-default 只会在键不存在或它的值为空时填充一个值。
规格
[
{
"operation": "modify-default-beta",
"spec": {
"shipping_address": {
"address": "@(2,payment_address.address)"
}
}
}
]
输入A,没有送货地址
{
"payment_address": {
"address": "some address"
},
"shipping_address": {}
}
生成输出 A,其中复制了帐单地址
{
"payment_address" : {
"address" : "some address"
},
"shipping_address" : {
"address" : "some address"
}
}
输入B,其中有一个shipping_address
{
"payment_address": {
"address": "some address"
},
"shipping_address": {
"address": 1234
}
}
生成输出 B,其中送货地址不会被覆盖。
{
"payment_address" : {
"address" : "some address"
},
"shipping_address" : {
"address" : 1234
}
}
这是我的输入JSON:
{
"AddressBilling": {
"FirstName": "Some Name",
"LastName": "Some Name",
"Address":"some address"
}
"AddressShipping": {
"FirstName": "",
"LastName": "",
"Address":""
}
}
我想保留 "AddressBilling" 和 "AddressShipping" 但名称不同 i:e "payment_address" 和 "shipping_address",我为此编写了一个规范文件payment_address”部分
{
"operation": "shift",
"spec": {
"AddressBilling": {
"FirstName": "payment_address.firstname",
"LastName": "payment_address.lastname",
"Address": "payment_address.address"
},
"AddressShipping": {
"FirstName": "shipping_address.firstname",
"LastName": "shipping_address.lastname"
}
}
}
现在我想要的是检查 "AddressShipping" 对象中的 "Address" 键是否为 null 然后我想将 "AddressBilling" 的 "Address" 复制到 "Address" "shipping_address".
可以用 "modify-default" 做到这一点。 Modify-default 只会在键不存在或它的值为空时填充一个值。
规格
[
{
"operation": "modify-default-beta",
"spec": {
"shipping_address": {
"address": "@(2,payment_address.address)"
}
}
}
]
输入A,没有送货地址
{
"payment_address": {
"address": "some address"
},
"shipping_address": {}
}
生成输出 A,其中复制了帐单地址
{
"payment_address" : {
"address" : "some address"
},
"shipping_address" : {
"address" : "some address"
}
}
输入B,其中有一个shipping_address
{
"payment_address": {
"address": "some address"
},
"shipping_address": {
"address": 1234
}
}
生成输出 B,其中送货地址不会被覆盖。
{
"payment_address" : {
"address" : "some address"
},
"shipping_address" : {
"address" : 1234
}
}