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

Retrieving data based on length of the string fields #320

Open
ngarg-kr opened this issue Mar 27, 2023 · 1 comment
Open

Retrieving data based on length of the string fields #320

ngarg-kr opened this issue Mar 27, 2023 · 1 comment

Comments

@ngarg-kr
Copy link

For a sample payload like this

{
  "name": {"first": "Tom", "last": "Anderson"},
  "age":37,
  "children": ["Sara","Alex","Jack"],
  "fav.movie": "Deer Hunter",
  "friends": [
    {"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]},
    {"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]},
    {"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]}
  ]
}

I need the last name of those friends whose first name is of 5 characters which will be Craig in this case.

@tidwall is this possible to write such query?

@volans-
Copy link

volans- commented Mar 27, 2023

@ngarg-kr I didn't try it, but I think that if you register a custom modifier to calculate the length, let's say @len, you might be able to get what you're looking for with:

friends.#(first.@len==5)#.last

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

2 participants