JArray Select/LinQ to select positions

Hi, I have a JArray (of size 21.000) that for each entry, contains the keys “Name”, “Price”, and “URL”.

What I need, is to be able to get ONLY all the entries with a specific “URL” value.
Meaning getting the “Name”, “Price” and “URL” of each entry in the JArray that contains a specific value of “URL”.

I’m new at using Select, Where, and LinQ. But I know that what I want can be achieved using them.

Does anyone know and would be willing to help me achieve this?.

Hi,

Can you share specific sample? It’s no problem if dummy data.

Regards,

Hi. Here is an example of 4 entries in my JSON.

  • The URL will always be unique and the name can be repeated for different “products”.
  • In this example, what I would want is to retrieve the “Name”, “URL” and “Price” for all the entries with the value “www.the-thing-i-want.com” in the key “URL”.
[
  {
    "Name": "A",
    "URL": "www.something.com",
    "Price": 10.41
  },
  {
    "Name": "B",
    "URL": "www.another-thing.com",
    "Price": 8.67
  },
  {
    "Name": "C",
    "URL": "www.the-thing-i-want.com",
    "Price": 2.6
  },
  {
    "Name": "C",
    "URL": "www.the-thing-i-want.com",
    "Price": 3.2
  }
]

Hi,

Which type do you need as result?

The following returns filtered datatable and jarray.

Hope this helps you.

Regards,

1 Like

Hi,

The following will work. Can you try this?

 ja = New JArray(ja.Where(Function(j) j("URL").ToString.Contains("www.the-thing-i-want.com")))

note: ja is JArray

Regards,

1 Like

Finally I have a way to filter my JArray, thank you!

And I feel dumb for my previous message, I deleted it after re-checking the image you sent and recognizing my mistake. I speed read it and basically I messed up.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.