Skip to Content
0
Jan 31, 2023 at 04:42 PM

How to format nested JSON Structures?

222 Views

Hi dear Community,

I have tried to convert a 3-level nested json structure using JavaScript inside an integration stream with very bad results: it turns out that when capturing the incoming JSON body, CPI saves said value as an InputStreamCache (org.apache.camel.converter.stream .InputStreamCache@5e5b86bd) , when trying to use the JSON.stringify function it does not finish correctly, since the input variable obtained is considered a special text or different storage format within the stream.

I would really appreciate if anyone has an easy way to convert to String or directly access the fields within the nested JSON for processing.

I attach a test plot for the exposed case.

{

"ABC": {

"DCE": [

{

"FGH": [

{

"A1": 54,

"A2": "0090106604",

"A3": "20230123",

"A4": 1,

"A5": "20230123",

"A6": "070107",

"A7": "021101",

"A8": "AV. CRNL. NESTOR GAMBETTA NRO. 3235 (ALT. KM.3.6) PROV. CONST. DEL CALLAO PROV.",

"A9": "CAMPAMENTO MINERO ANTAMINA - SAN MARCOS HUARI- ANCASH",

"A10": "20100039207",

"A11": "RENSOU COMERCIAL S.A.C",

"A12": "Q45510345",

"A13": "ADOLF HUANG ATACGUA",

"A14": "BKF742",

"A15": "B4A593",

"A16": "ENTRE ESTABLECIMIENTOS",

"A17": "5000000546",

"A18": "2023",

"A19": "1",

"A20": "RA201770",

"A21": "ANILLO GUIADOR",

"A22": "000000001101232685",

"A23": "Juego 13 llaves allen de .050" a 3/8"",

"A24": "4500001170",

"A25": 10,

"A26": "T001-14457",

"A27": 1.0

}

]

}

]

}

}

Best regards,

JR