Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by nested array value #875

Open
enricopalazzo opened this issue Oct 18, 2018 · 4 comments
Open

Filter by nested array value #875

enricopalazzo opened this issue Oct 18, 2018 · 4 comments

Comments

@enricopalazzo
Copy link

I have a json structure like this:

"users": [
    {
      "id": 1,
      "first_name": "Erek",
      "urbs":[
        {
          "id": 12
        },
        {
          "id": 8
        }
      ] 
       
    },
    {
      "id": 2,
      "first_name": "Ladonna",
      "urbs": [
        {
          "id": 7
        }
      ]
    },
    {
      "id": 3,
      "first_name": "Lezley",
      "urbs": [
        {
          "id": 10
        }
      ]
    },
    {
      "id": 4,
      "first_name": "Rick",
      "urbs":[
        {
          "id": 14
        },
        {
          "id": 12
        }
      ] 
       
    }
]

Is there a way to get all users where the urbs array contain an object with id = 12 ?

I've tried many things, and this is the closest I got to my goal:
http://localhost:3000/users?urbs.0.id=12

This works, but only when id = 12 is in the first position of the array.
I have no way of knowing the position of the value inside the array.

@ZenwalkerD
Copy link

Unfortunately for me the similar thing what you have done above doesnt work.
My JSON is:

{
  "products": [
    {
      "productName": "Pipe",
      "productCode": "1-",
      "productAvailable": true,
      "productPrice": 122,
      "productRating": 4,
      "productDescription": "blahblah.",
      "productImageURL": "170767/1340130900.svg",
      "productComments": [
        {
          "id": 0,
          "dislikes": 0,
          "likes": 0,
          "comment": "asd"
        },
        {
          "id": 1,
          "dislikes": 0,
          "likes": 0,
          "comment": "asdaddsadadasd"
        }
      ]
    }
 ]
}

Having URL like this http://localhost:3000/products?productComments.0.id doesnt work at all :(

@brandonros
Copy link

any solution ever found?

1 similar comment
@wesClyton
Copy link

any solution ever found?

@SalahAdDin
Copy link

Any solution till today?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants