Skip to main content
Atish-123
Silver ⭐️⭐️
August 22, 2024
Question

JOLT SPEC

Hi team I want a jolt spec where I want the output to be completely flattened json. this is my input json and assuming where ever there is nested array it should be mapped with other nested array as well. this is my input json - 

{
"unitOfMeasure": "unit:piece",
"linkedDemandSeries": [
{
"loadFactor": 3.5,
"materialNumberCustomer": "MNR-7307-AU340474.002",
"materialNumberSupplier": "MNR-8101-ID146955.001",
"customerLocation": "{{CATENAX-CUSTOMER-BPNS}}",
"demandCategory": {
"demandCategoryCode": "0001"
}
},
{
"loadFactor": 4.0,
"materialNumberCustomer": "MNR-7307-AU340474.002",
"materialNumberSupplier": "MNR-8101-ID146955.001",
"customerLocation": "{{CATENAX-CUSTOMER-BPNS}}",
"demandCategory": {
"demandCategoryCode": "0002"
}
}
],
"linkedCapacityGroups": [
"be4d8470-2de6-43d2-b5f8-2e5d3eebf3fd",
"ab4d8470-2de6-43d2-b5f8-2e5d3eebf3fd"
],
"unitOfMeasureIsOmitted": false,
"capacityGroupIsInactive": true,
"demandVolatilityParameters": {
"rollingHorizonAlertThresholds": [
{
"sequenceNumber": 1,
"absoluteNegativeDeviation": 100.0,
"subhorizonLength": 4,
"relativeNegativeDeviation": 0.3,
"absolutePositiveDeviation": 100.0,
"relativePositiveDeviation": 0.2
}
],
"measurementInterval": 4,
"startReferenceDateTime": "2024-01-10T12:00:00.320Z"
},
"supplier": "{{CATENAX-SUPPLIER-BPNL}}",
"name": "Spark Plugs on drilling machine for car model XYZ",
"supplierLocations": [
"{{CATENAX-SUPPLIER-BPNS}}",
"{{CATENAX-SUPPLIER-BPNS-1}}"
],
"capacities": [
{
"pointInTime": "2022-08-01",
"agreedCapacity": 1800,
"actualCapacity": 1000,
"maximumCapacity": 2000,
"deltaProductionResult": 400
}
],
"changedAt": "2023-03-10T12:27:11.320Z",
"capacityGroupId": "0157ba42-d2a8-4e28-8565-7b07830c1110",
"customer": "{{CATENAX-CUSTOMER-BPNL}}"
}.    The output should look like this. - 
[
{
"unitOfMeasure": "unit:piece",
"loadFactor": 3.5,
"materialNumberCustomer": "MNR-7307-AU340474.002",
"materialNumberSupplier": "MNR-8101-ID146955.001",
"customerLocation": "{{CATENAX-CUSTOMER-BPNS}}",
"demandCategoryCode": "0001",
"linkedCapacityGroups": "be4d8470-2de6-43d2-b5f8-2e5d3eebf3fd",
"unitOfMeasureIsOmitted": false,
"capacityGroupIsInactive": true,
"sequenceNumber": 1,
"absoluteNegativeDeviation": 100,
"subhorizonLength": 4,
"relativeNegativeDeviation": 0.3,
"absolutePositiveDeviation": 100,
"relativePositiveDeviation": 0.2,
"measurementInterval": 4,
"startReferenceDateTime": "2024-01-10T12:00:00.320Z",
"supplier": "{{CATENAX-SUPPLIER-BPNL}}",
"name": "Spark Plugs on drilling machine for car model XYZ",
"supplierLocations": "{{CATENAX-SUPPLIER-BPNS}}",
"pointInTime": "2022-08-01",
"agreedCapacity": 1800,
"actualCapacity": 1000,
"maximumCapacity": 2000,
"deltaProductionResult": 400,
"changedAt": "2023-03-10T12:27:11.320Z",
"capacityGroupId": "0157ba42-d2a8-4e28-8565-7b07830c1110",
"customer": "{{CATENAX-CUSTOMER-BPNL}}"
},
{
"unitOfMeasure": "unit:piece",
"loadFactor": 3.5,
"materialNumberCustomer": "MNR-7307-AU340474.002",
"materialNumberSupplier": "MNR-8101-ID146955.001",
"customerLocation": "{{CATENAX-CUSTOMER-BPNS}}",
"demandCategoryCode": "0001",
"linkedCapacityGroups": "ab4d8470-2de6-43d2-b5f8-2e5d3eebf3fd",
"unitOfMeasureIsOmitted": false,
"capacityGroupIsInactive": true,
"sequenceNumber": 1,
"absoluteNegativeDeviation": 100,
"subhorizonLength": 4,
"relativeNegativeDeviation": 0.3,
"absolutePositiveDeviation": 100,
"relativePositiveDeviation": 0.2,
"measurementInterval": 4,
"startReferenceDateTime": "2024-01-10T12:00:00.320Z",
"supplier": "{{CATENAX-SUPPLIER-BPNL}}",
"name": "Spark Plugs on drilling machine for car model XYZ",
"supplierLocations": "{{CATENAX-SUPPLIER-BPNS}}",
"pointInTime": "2022-08-01",
"agreedCapacity": 1800,
"actualCapacity": 1000,
"maximumCapacity": 2000,
"deltaProductionResult": 400,
"changedAt": "2023-03-10T12:27:11.320Z",
"capacityGroupId": "0157ba42-d2a8-4e28-8565-7b07830c1110",
"customer": "{{CATENAX-CUSTOMER-BPNL}}"
}
] can anyone give me jolt spec for the input json I provided

5 replies

VidyaSargur
Community Manager
Community Manager
August 23, 2024

@Atish-123, Welcome to our community! To help you get the best possible answer, I have tagged our NiFi experts @MattWho @SAMSAL @vaishaakb who may be able to assist you further.

Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.

Translate
Regards, Vidya Sargur, Community Manager Was your question answered? Make sure to mark the answer as the accepted solution. If you find a reply useful, say thanks by clicking on the thumbs up button.
Atish-123
Atish-123Author
Silver ⭐️⭐️
August 23, 2024

hi @MattWho  can you give me jolt spec

Translate
vaishaakb
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
August 23, 2024

@Atish-123 Thank you for bringing this to our community.

Did you get a chance to review the Jolt Quick reference community article? If not, Please review: https://community.cloudera.com/t5/Community-Articles/Jolt-quick-reference-for-Nifi-Jolt-Processors/ta-p/244350

Let us know how it goes.

V

Translate
Atish-123
Atish-123Author
Silver ⭐️⭐️
August 23, 2024

I know basic of jolt and I did went through couple quick reference for jolt. but it was little bit confusing. can you give me the jolt spec for the one which I have asked

Translate
SAMSAL
Platinum ⭐️⭐️⭐️
August 24, 2024

Hi,

Welcome to the community. Can you elaborate more on how you want to flatten the input specially when you have multiple arrays with different cardinalities where sometimes you match by index and other (when the array count = 1) you seem to assign to all. Also your sample input seem to have some matching values which makes it ambiguous  in figuring which value is being assigned to what array. When I look at the output all I see is  two identical objects where all the values seem to match which makes it even more confusing. 

Translate