cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Lookup on an array in the input document

IgnatiusN
New Contributor II

Hello,

I have a incoming JSON document that has cases and array of casesteps inside. I need to do a lookup on the case step code from a table in the database and add additional properties to the casestep. Is there a way to accomplish this? We tried doing SQL Lookup or In Memory lookup but joining with each case step on the code didnโ€™t work. The jsonPath syntax we were using always returned an array of codes and the lookup was failing. Any help is appreciated!

[
{
caseId: 1,
caseDate: โ€œ2017-08-04โ€,
caseSteps: [{
code: โ€œxyzโ€,
value: 10,
primary: null
},
{
code: โ€œabcโ€,
value: 20,
primary: null
},
{
code: โ€œdefโ€,
value: 20,
primary: null
}]
},
{
caseId: 2,
caseDate: โ€œ2017-08-04โ€,
caseSteps: [{
code: โ€œrewโ€,
value: 10,
primary: null
},
{
code: โ€œwbcโ€,
value: 20,
primary: null
},
{
code: โ€œwweโ€,
value: 20,
primary: null
}]
}
]

Thanks

10 REPLIES 10

nganapathiraju
Former Employee

[{, โ€ฆ}, {, โ€ฆ}]
{codeArr:[xyz, abc, def], codeStr:xyz,abc,def}
โ€œcodeArrโ€: [xyz, abc, def]
โ€œxyzโ€,
โ€œabcโ€,
โ€œdefโ€
โ€œcodeStrโ€: โ€œxyz,abc,defโ€
{codeArr:[rew, wbc, wwe], codeStr:rew,wbc,wwe}
โ€œcodeArrโ€: [rew, wbc, wwe]
โ€œrewโ€,
โ€œwbcโ€,
โ€œwweโ€

โ€œcodeStrโ€: โ€œrew,wbc,wweโ€

Is this what you were expecting? of course if you want a single value from the code, you would need to define the criteria.

You can further do all variations

image

PS: It would be nice if you pasted your entire RAW json. I had to plugin the "" around all json elements and jsonify it to get the exact format.

IgnatiusN
New Contributor II

Thank you for your response, and sorry for the inconvenience with JSON. My requirement is little different. Given the original JSON source, I have to do a lookup on a second JSON source and add the exp_time property to the case step

[
{
โ€œcodeโ€: โ€œabcโ€,
โ€œexp_timeโ€: โ€œ30sโ€
},
{
โ€œcodeโ€: โ€œxyzโ€,
โ€œexp_timeโ€: โ€œ20sโ€
},
{
โ€œcodeโ€: โ€œdefโ€,
โ€œexp_timeโ€: โ€œ40sโ€
}
]

The output we are expecting is something like

[
{
โ€œcaseIdโ€: 1,
โ€œcaseDateโ€: โ€œ2017-08-04โ€,
โ€œcaseStepsโ€: [{
โ€œcodeโ€: โ€œxyzโ€,
โ€œvalueโ€: 10,
โ€œprimaryโ€: null,
โ€œexp_timeโ€: โ€œ20sโ€
},
{
โ€œcodeโ€: โ€œabcโ€,
โ€œvalueโ€: 20,
โ€œprimaryโ€: null,
โ€œexp_timeโ€: โ€œ30sโ€
},
{
โ€œcodeโ€: โ€œdefโ€,
โ€œvalueโ€: 20,
โ€œprimaryโ€: null,
โ€œexp_timeโ€: โ€œ40sโ€
}]
}
]

please post the second json source and mention the condition you want to join.

You can add exp_time to caseSteps in the mapper snap.

image

That was just a sample to manipulate JSON but you can achieve more granularity.

IgnatiusN
New Contributor II

Thanks Again, the second json source is given in the post. I have it here again. The join is on the โ€œcodeโ€ from โ€œcasestepโ€ to the โ€œcodeโ€ in this source. exp_time from second source has to be copied over the main document

[
{
โ€œcodeโ€: โ€œabcโ€,
โ€œexp_timeโ€: โ€œ30sโ€
},
{
โ€œcodeโ€: โ€œxyzโ€,
โ€œexp_timeโ€: โ€œ20sโ€
},
{
โ€œcodeโ€: โ€œdefโ€,
โ€œexp_timeโ€: โ€œ40sโ€
}
]