Forum Discussion

deepak_shaw's avatar
deepak_shaw
Contributor
5 years ago

2nd object from json object array

Question: I have input JSON array

[

{“name”:“AU”, “value”: 3},

{“name”:“US”, “value”: 1},

]

I want to have 2nd object i.e. {“name”:“US”, “value”: 1}

please advise how to get it?
Thanks,
DK

2 Replies

  • viktor_n's avatar
    viktor_n
    Contributor II

    Hi @deepak.shaw,

    If they are documents then you can use Gate snap and after gate you just select $input0[1], and it will return you always the second document. But if you want last document than use Tail snap.

    Note: Gate snap will wait all documents to come on input and after will return you the data.

  • Thanks for the reply.
    Actually, I’m receiving the message from Kafka Consumer like: