|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
|
|
how to make request JSON Object Array Nested using esql |
« View previous topic :: View next topic » |
Author |
Message
|
tuantampan |
Posted: Thu Jun 30, 2022 3:37 am Post subject: how to make request JSON Object Array Nested using esql |
|
|
Newbie
Joined: 30 Jun 2022 Posts: 1
|
How to make request json like that using esql
Example Request:
Code: |
{
"MC":"700801",
"CID":"MDW-TPREXT-0001",
"DT":"20221212090809",
"ST": "902925",
"cabang": "MELAWAI",
"kodeMitra": "22011004",
"namaOperator": "NARAY CITRA",
"jumlah": 1,
"peserta":[
{
"hasilKPR": false,
"kolektibilitas": 1,
"namaPeserta": "ROSIDAH",
"nomorPeserta": "2542850174"
},
{
"hasilKPR": false,
"kolektibilitas": 1,
"namaPeserta": "ASINAN",
"nomorPeserta": "2542850175"
}
]
} |
I try like that in esql but not works
Code: |
CREATE FIELD OutputRoot.JSON.Data.peserta IDENTITY(JSON.Array);
DECLARE count INT CARDINALITY(OutputLocalEnvironment.OriginalPost.JSON.Data.peserta[]);
DECLARE i INT 1;
WHILE i <= count DO
SET OutputRoot.JSON.Data.peserta.Item[i].nomorPeserta = InputLocalEnvironment.OriginalPost.JSON.Data.peserta[i].nomorPeserta ;
SET i = i + 1;
END WHILE;
SET OutputRoot.JSON.Data.cabang = reqData.cabang; |
Result in log
Code: |
"JSON" :
{
"Data" :
{
"peserta" :
{ }
,
"cabang" : "MELAWAI"
}
} |
[/code] |
|
Back to top |
|
|
timber |
Posted: Mon Jul 04, 2022 6:17 am Post subject: |
|
|
Grand Master
Joined: 25 Aug 2015 Posts: 1290
|
1. Create a test message flow with an input node (any kind will do) and a Trace node, and set the Domain to JSON
2. Add a Trace node after the Input node and set the pattern to ${Root}
3. Send your required JSON message into the test flow, and collect the trace
4. In the real message flow, use the output from the Trace node as your guide. Write ESQL to create exactly the same message tree. Pay special attention to the field types on each node in the message tree. |
|
Back to top |
|
|
gabrielj |
Posted: Thu Jul 14, 2022 3:08 am Post subject: |
|
|
Novice
Joined: 16 Nov 2014 Posts: 23 Location: Muscut,Perth,Sydney,Bangalore,Hydrabad,Coimbatore
|
Use this code
Code: |
SET OutputRoot.JSON.Data.MC = '700801';
SET OutputRoot.JSON.Data.CID = 'MDW-TPREXT-0001';
SET OutputRoot.JSON.Data.DT = '20221212090809';
SET OutputRoot.JSON.Data.ST = '902925';
SET OutputRoot.JSON.Data.cabang = 'MELAWAI';
SET OutputRoot.JSON.Data.kodeMitra = '1233';
SET OutputRoot.JSON.Data.namaOperator = 'NARAY CITRA';
SET OutputRoot.JSON.Data.jumlah = '1';
CREATE FIELD OutputRoot.JSON.Data.peserta IDENTITY(JSON.Array)peserta;
SET OutputRoot.JSON.Data.peserta.Item[1].hasilKPR=false;
SET OutputRoot.JSON.Data.peserta.Item[1].namaPeserta='ROSIDAH';
SET OutputRoot.JSON.Data.peserta.Item[2].hasilKPR=false;
SET OutputRoot.JSON.Data.peserta.Item[2].namaPeserta='ASINAN';
|
|
|
Back to top |
|
|
|
|
|
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|