Forum Discussion

npise's avatar
npise
New Contributor II
4 years ago
Solved

Find a specific word in Json Object

In the router i am trying to route data based on below criteria

if any of the value in statusC.contains("T’) route to view1
if any of the value in !statusC.contains("T’). (does not contains) route to view2

How can i best achieve from below data

[
{
 "group" : [
{
"statusC":"T"
},
{
"statusC":"T"
}
 ]
},
{
 "group" : [
{
"statusC":"A"
},
{
"statusC":"A"
}
 ]
},
{
 "group" : [
{
"statusC":"T"
},
{
"statusC":"A"
}
 ]
},
{
 "group" : [
{
"statusC":"A"
},
{
"statusC":"T"
}
 ]
}
]

  • Hi @npise,

    I am sure that @Supratim was referring to output0 and output1 on the router, and not to a conditional operator. Configured router with his expression will do the job :

4 Replies

  • bojanvelevski's avatar
    bojanvelevski
    Valued Contributor

    Hi @npise,

    I am sure that @Supratim was referring to output0 and output1 on the router, and not to a conditional operator. Configured router with his expression will do the job :

  • Supratim's avatar
    Supratim
    Contributor III

    @npise use the expression - jsonPath($, “$group[?(@.statusC == ‘T’)]”).length > 0 : route to view1 else view2

  • npise's avatar
    npise
    New Contributor II

    Thanks for the response

    I am using a router snap and i dont think i can use conditional.