Created 08-26-2024 10:21 PM
so i am working on NIFI and we are converting and sorting our .asn file into json file so right now for this i am using some processors
this all processors i am using , now i want to change name of existing variable into input file means i am having 2 resultcode in my input file and output is coming like this resultcode = {2001,2001} now i want the second value to come under resultcodemscc what processor i can use here ? my input after jolt looks like "sessionStopTime" : "09/07/2024 06:47:19",
"resultCode" : [ "2001", "2001" ],
"recordOpeningTime" : "09/07/2024 06:44:22"
this is all live data i cant hardcode the value , pls suggest something ASAP !
Created 08-27-2024 05:28 AM
Hi,
Its not clear from your description what is the input json format and what is the expected output format, but from what I was able to understand from your description you have the following json:
{
"sessionStopTime": "09/07/2024 06:47:19",
"resultCode": [
"2001",
"2001"
],
"recordOpeningTime": "09/07/2024 06:44:22"
}
And you want to produce new attribute for the second array element of resutltCode to be stored in another field like this even though in your case both array elements are the same:
{
"sessionStopTime": "09/07/2024 06:47:19",
"resultCode": [
"2001",
"2001"
],
"resultcodemscc":"2001",
"recordOpeningTime": "09/07/2024 06:44:22"
}
If this the case then Jolt spec would look like this:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"resultcodemscc": "=elementAt(@(1,resultCode),1)"
}
}
]
If that helps please accept solution.
Thanks
Created 08-28-2024 10:42 AM
so this is my input data for jolt transformer
{
"recordType" : "OC",
"recordElements" : [ {
"varName" : "preame",
"varValue" : "z"
}, {
"varName" : "recdId",
"varValue" : "2024b"
}, {
"varName" : "genertamp",
"varValue" : "09/07/2024 06:47:19"
}, {
"varName" : "sesnId",
"varValue" : "dd"
"varName" : "servitextId",
"varValue" : "322p.org"
}, {
"varName" : "requestType",
"varValue" : "TEST"
}, {
"varName" : "nccVersion",
"varValue" : "SPS3_R1"
}, {
"varName" : "RecordTimestamp",
"varValue" : "09/0:19"
} ],
"recordExtensions" : [ {
"recordProperty" : "listOfSubonID",
"recordElements" : null,
"recordSubExtensions" : [ {
"recordProperty" : "subscrinId",
"recordElements" : [ {
"varName" : "subscrinIdType",
"varValue" : "1"
}, {
"varName" : "subscriptionIdData",
"varValue" : "219014523"
} ],
"recordSubExtensions" : null
}, {
"recordProperty" : "subscriptionId",
"recordElements" : [ {
"varName" : "subscriptionIdType",
"varValue" : "0"
}, {
"varName" : "subscriptionIdData",
"varValue" : "385993101133"
} ],
"recordSubExtensions" : null
} ]
}, {
"recordProperty" : "listOfMscc",
"recordElements" : null,
"recordSubExtensions" : [ {
"recordProperty" : "mscc",
"recordElements" : [ {
"varName" : "ratingGroup",
"varValue" : "40"
}, {
"varName" : "serviceIdentifier",
"varValue" : "100"
}, {
"varName" : "chargingType",
"varValue" : "ONLRGING"
}, {
"varName" : "recordEventType",
"varValue" : "PS"
}, {
"varName" : "reportReason",
"varValue" : "FINAL"
}, {
"varName" : "firstDataStart",
"varValue" : "09/044:22"
}, {
"varName" : "lastDataUsage",
"varValue" : "09/0:47:19"
}, {
"varName" : "timeUsage",
"varValue" : "177"
}, {
"varName" : "usedUnitType",
"varValue" : "TL"
}, {
"varName" : "resultCode",
"varValue" : "2001"
}, {
"varName" : "downnsumed",
"varValue" : "41619"
} ],
and if you can see i have 2 result code 1st at the starting and another 1 is under mscc and i am getting output of this as both coming under resultcode like resultcode {2001,2001 } but i want 2nd one will come like resultcodemscc = 2001 here is my jolt spec and output of that jolt spec ------
[
{
"operation": "shift",
"spec": {
"recordType": "recordType",
"recordElements": {
"*": {
"varValue": "@(1,varName)"
}
},
"recordExtensions": {
"*": {
"recordProperty": "&",
"recordSubExtensions": {
"*": {
"recordProperty": "&",
"recordElements": {
"*": {
"varValue": "@(1,varName)"
}
}
}
},
"recordSubExtensions": {
"*": {
"recordProperty": "&",
"recordElements": {
"*": {
"varValue": "@(1,varName)"
}
},
"recordSubExtensions": {
"*": {
"recordProperty": "&",
"recordSubExtensions": {
"*": {
"recordProperty": "&",
"recordElements": {
"*": {
"varValue": "@(1,varName)"
}
},
"recordSubExtensions": {
"*": {
"recordProperty": "&",
"recordElements": {
"*": {
"varValue": "@(1,varName)"
}
},
"recordSubExtensions": {
"*": {
"recordProperty": "&",
"recordElements": {
"*": {
"varValue": "@(1,varName)"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
]
and output is coming like
"resultCode" : [ "2001", "2001" ],
Created 08-28-2024 10:44 AM
varValue: 02F210
- varName: rATType
varValue: '2'
- varName: resultCode
varValue: '2001'
- varName: recordOpeningTime
this is the 1st resultcode present at starting