Some help with Jtoken

[
   [
      {
         "id":1000000000026,
         "name":"ONE COMPANY",
         "desc":"one has one",
         "partner":"one one"
      },
      {
         "id":2589,
         "name":"TWO COMPANY",
         "desc":"two has two",
         "partner":"two two"
      },
      {
         "id":1000000000005,
         "name":"THREE COMPANY",
         "desc":"three has three",
         "partner":"three three"
      }
   ],
   [
      {
         "id":1000000000005,
         "name":"PREMIUM COMPANY",
         "desc":"premium has vip",
         "partner":"premium premium"
      }
   ]
]

So have a look at this JSON.

Here I want a Jtoken to parse two arrays here

one array has ONE, TWO, THREE companies
and second, has PREMIUM COMPANY

I want to receive two list items in ob2, all of the descriptions in one list value and the description of 2nd array in another list value

Example output I need →

description (list) = [one has one + two has two + three has three, premium has VIP]

I am sure there is a way for this in Jtoken but I am not getting it! if anyone here is pro in Jtoken Please try the solution!

Paste your JSON in the left editor and paste this in the top box

$.[*].[*].desc

You can see output on the right side

1 Like

Dude @Ruri I know this much Jtoken Btw :neutral_face:, you see I wanted to get each array separately, like in this case there are two arrays [normal companies] [premium companies]
I want them separately

but here it’s merging both of the arrays in one, and the point to note is that no.of arrays are dynamic

image

what I want is two get one array in one list item and another array in another list iterm

Oh, I see. So the first array has all the non-premium ones and the second has the premium ones? If so then it’s as easy as doing $.[0].[*].desc and $.[1].[*].desc ^^

Otherwise if they could be mixed together, this expression will grab all the ones with the word premium in the desc field by using a regex. Try if it works inside OB2, I hope it does!

$.[*].[?(/premium/.test(@.desc))].desc
1 Like

I don’t think that helped that much buddy, i guess i will post this question in stackoverflow once and see what’s the perfect answer for this, as i said they are dynamic, its not about the premium or any other thing, i just want to parse the values of desc in each array separately its not about the order of them, i am too good in Jtoken and regex but this is like very tough for me Lol :joy:

anyways thanks for your effort! :slightly_smiling_face:

2 Likes