Reputation: 13
Below is the input ,spec and output spec and the expected spce. here in the outputspec we are getting the tag with the empty values, That empty tag needs to be removed from the output jolt.
Below will be the input spec: Input spec:
{
"feature": [],
"note": [],
"place": [],
"relatedEntity": [],
"relatedParty": [],
"characteristic": [
{
"name": "SerialNo",
"characteristicRelationship": [],
"value": "4200000065",
"@type": "String",
"arrayIndex": "-1"
},
{
"name": "Card_Status",
"characteristicRelationship": [],
"value": "Deactivated",
"@type": "String",
"arrayIndex": "-1"
},
{
"name": "Card_Type",
"characteristicRelationship": [],
"value": "SCRATCH1",
"@type": "string",
"arrayIndex": "-1"
},
{
"name": "FaceValue",
"characteristicRelationship": [],
"value": "1000000",
"@type": "string",
"arrayIndex": "-1"
},
{
"name": "cardExpiryDate",
"characteristicRelationship": [],
"value": "11",
"@type": "string",
"arrayIndex": "-1"
},
{
"name": "Recharge_Amount",
"characteristicRelationship": [],
"value": "1000000",
"@type": "string",
"arrayIndex": "-1"
},
{
"name": "MSISDN",
"characteristicRelationship": [],
"value": "237654567",
"@type": "string",
"arrayIndex": "-1"
},
{
"name": "manufacturer_order_no",
"characteristicRelationship": [],
"value": "47",
"@type": "string",
"arrayIndex": "-1"
},
{
"name": "time_of_usage",
"characteristicRelationship": [],
"value": "2027-12-31T00:00:00.000Z",
"@type": "string",
"arrayIndex": "-1"
}
],
"serviceOrderItem": [],
"serviceRelationship": [],
"supportingResource": [],
"supportingService": [],
"responseHeader": {
"requestId": "CRM3inpmh_1723552012193",
"responeId": "CRM3inpmh_1723552012193",
"responseMessage": "Success",
"responseStatus": "200",
"responseTimestamp": "2024-08-13T17:56:52.425Z",
"source": "cellcardESB"
}
}
Current jolt spec:
[
{
"operation": "shift",
"spec": {
"responseHeader": {
"responseMessage": "resultDesc",
"responseStatus": "resultcode"
},
"characteristic": {
"*": {
"value": {
"@(1,value)": "@(2,arrayIndex).@(2,name)"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"-1": "bundlelist[]",
"*": "RechargeResource[]",
"resultcode": "resultcode",
"resultDesc": "resultDesc"
}
},
{
"operation": "shift",
"spec": {
"resultcode": "resultcode",
"resultDesc": "resultDesc",
"bundlelist": {
"*": {
"SerialNo": "datas.cardDetails.[&1].cardSerialNumber",
"Card_Status": "datas.cardDetails.[&1].cardStatus",
"cardValue": "datas.cardDetails.[&1].cardValue",
"Card_Type": "datas.cardDetails.[&1].cardType",
"FaceValue": "datas.cardDetails.[&1].faceValue",
"cardExpiryDate": "datas.cardDetails.[&1].cardStopDate",
"Recharge_Amount": "datas.cardDetails.[&1].rechargeAmount",
"MSISDN": "datas.cardDetails.[&1].msisdn",
"manufacturer_order_no": "datas.cardDetails.[&1].manufacturerOrderNo",
"time_of_usage": "datas.cardDetails.[&1].timeUsage"
}
},
"RechargeResource": {
"*": {
"SerialNo": "datas.cardDetails.[&1].cardSerialNumber",
"Card_Status": "datas.cardDetails.[&1].cardStatus",
"cardValue": "datas.cardDetails.[&1].cardValue",
"Card_Type": "datas.cardDetails.[&1].cardType",
"FaceValue": "datas.cardDetails.[&1].faceValue",
"cardExpiryDate": "datas.cardDetails.[&1].cardStopDate",
"Recharge_Amount": "datas.cardDetails.[&1].rechargeAmount",
"MSISDN": "datas.cardDetails.[&1].msisdn",
"manufacturer_order_no": "datas.cardDetails.[&1].manufacturerOrderNo",
"time_of_usage": "datas.cardDetails.[&1].timeUsage"
}
}
}
}
]
current output:
{
"resultcode": "200",
"resultDesc": "Success",
"datas": {
"cardDetails": [
{
"cardSerialNumber": "4200000065",
"cardStatus": "Deactivated",
"cardType": "SCRATCH1",
"faceValue": "1000000",
"cardStopDate": "",
"rechargeAmount": "1000000",
"msisdn": "237654567",
"manufacturerOrderNo": "47",
"timeUsage": "2027-12-31T00:00:00.000Z"
}
]
}
}
Note: If any of the field value is empty or null that needs to be removed.
expected output like below:
{
"resultcode": "200",
"resultDesc": "Success",
"datas": {
"cardDetails": [
{
"cardSerialNumber": "4200000065",
"cardStatus": "Deactivated",
"cardType": "SCRATCH1",
"faceValue": "1000000",
"rechargeAmount": "1000000",
"msisdn": "237654567",
"manufacturerOrderNo": "47",
"timeUsage": "2027-12-31T00:00:00.000Z"
}
]
}
}
Upvotes: 1
Views: 30
Reputation: 65313
Indeed what you need is this much ( principally matching value
vs. name
) except for renaming of the attributes :
[
{
"operation": "shift",
"spec": {
"responseHeader": {
"responseStatus|responseMessage": "&"
},
"characteristic": {
"*": {
"@value": "datas.cardDetails[0].@name"
}
}
}
}
]
converting to the one with renaming, you can make :
[
{
"operation": "shift",
"spec": {
"responseHeader": {
"responseStatus|responseMessage": "&"
},
"characteristic": {
"*": {
"@value": "datas.cardDetails[0].@name"
}
}
}
},
{
"operation": "shift",
"spec": {
"responseStatus": "resultcode",
"responseMessage": "resultDesc",
"datas": {
"*": {
"*": {
"SerialNo": "&3.&2[&1].cardSerialNumber",
"Card_Status": "&3.&2[&1].cardStatus",
"Card_Type": "&3.&2[&1].cardType",
"FaceValue": "&3.&2[&1].faceValue",
"cardExpiryDate": "&3.&2[&1].&",
"Recharge_Amount": "&3.&2[&1].rechargeAmount",
"MSISDN": "&3.&2[&1].msisdn",
"manufacturer_order_no": "&3.&2[&1].manufacturerOrderNo",
"time_of_usage": "&3.&2[&1].timeUsage"
}
}
}
}
}
]
Upvotes: 0