Hi Ruwan,

In CEP, if we are using custom mapping, we have to specify json paths for
each attribtue of the stream.
Currently there is no option available to iterate through the json arrray
if there are elements other than the array.

But as you have mentioned, it's possible to extract value of a specific
element of the array by direcly providing the index in the json path.
However, when providing wild cards in json paths, it will provide all the
matching elements of the array, as a json array. Therefore, if you are
using wildcards in the json path, you will have to retrieve the result as a
string.

Eg:


>
>
>
>
>
>
>
>
>
>
>
>
> *{    "recordsTotal": 100,    "recordsFiltered": 1000,    "data": [{
>         "uuid": "ABCD",            "severity": 100,            "inAction":
> false        },{            "uuid": "EFGH",            "severity": 10,
>         "inAction": true        }    ]}*
>

For above payload, if we are doing the custom mapping, for the attribute
uuid,

> *uuid = $.data[*].uuid*
>
it will provide the result as ["ABCD", "EFGH"] which is a string.

Therefore, the acctual value which is getting assigned to uuid will be
["ABCD", "EFGH"].
In this case we have to do some string manipulations to retrieve the exact
value we need.

Thanks,
Minudika

On Tue, Dec 11, 2018 at 11:50 AM Mohanadarshan Vivekanandalingam <
[email protected]> wrote:

>
>
> On Tue, Dec 11, 2018 at 11:43 AM Ruwan Yatawara <[email protected]> wrote:
>
>> Adding Dev Group.
>>
>> On Tue, Dec 11, 2018 at 11:41 AM Ruwan Yatawara <[email protected]> wrote:
>>
>>> Hi All,
>>>
>>> We have encountered a problem when sending json arrays as input events
>>> via http eventAdapterType. Basically, if inputs json contains an array in
>>> the root element level, everything works fine, if other elements exist in
>>> the json, at root level in addition to the array; see below structure :
>>>
>>> {
>>> "recordsTotal": 100,
>>> "recordsFiltered": 1000,
>>> *"data": [{*
>>> * "uuid": "ABCD",*
>>> * "severity": 10,*
>>> * "inAction": false*
>>> * },{*
>>> * "uuid": "EFGH",*
>>> * "severity": 10,*
>>> * "inAction": false*
>>> * }*
>>> * ]*
>>> }
>>>
>>> Input fails with a malformation exception. Note that when adding the
>>> mappings we opted to use the json path in format: *$.data[*].uuid* to
>>> refer to each uuid element inside the payload. However, this json path
>>> expression does not seem to be recognized by CEP. But when using absolute
>>> references indicating the array index: i.e. *$.data[1].uuid *, everything
>>> works as expected.
>>>
>>> This appears to be an issue in CEP. Can you please advise on how we can
>>> work this out?
>>>
>>> Thanks and Regards,
>>> Ruwan
>>>
>>>
>>>
>
> --
> *V. Mohanadarshan* | Technical Lead | WSO2 Inc. <http://www.wso2.com/> |
> (M) 94-771117673 | (E) [email protected] |
> GET INTEGRATION AGILE
> Integration Agility for Digitally Driven Business
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>


-- 
*Minudika Gammanpila*
Software Engineer - WSO2

Email   :  [email protected]
Mobile :  +94715659887
Web     :  http://wso2.com

<http://wso2.com> <http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to