-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
support get_json_array #52616
Comments
Note: This issue is related to #52585. |
Thanks! could you pls give a demo and description about how you want to implement this? like the function's name, input, output and examples. just want to make sure we are on the same page. also some reference will be even better. |
Use select js->'$.people[*].name'
from (
select parse_json('
{
"people": [{
"name": "Daniel",
"surname": "Smith"
}, {
"name": "Lily",
"surname": "Smith",
"active": true
}]
}') as js) t Here are more examples. You even can case a complex JSON array to an Array. select cast(parse_json('[{"a":1}, {"a":2, "b":3}]') as Array<JSON>) as array_json
However, if you want to do more complex filter on JSON array with some Array functinos, maybe it's not easy. You can give more real cases to have a test. |
Thanks @jaogoy . Your guide have solved my problems. And one more question, don't you know some function to solve below issue? |
array_length(array_intersect) could solve my problem. |
{
"people": [{
"name": "Daniel",
"surname": "Smith"
}, {
"name": "Lily",
"surname": "Smith",
"active": true
}]
}
For example, I have a JSON field in this format, and I want to query for rows where the user's name is "jack." However, there is no function like get_json_array available. Although I can extract the result using $[*].name, there's currently no way to convert this result into an array.
If the community finds this reasonable, I might try implementing this method, get_json_array. @wangsimo0
The text was updated successfully, but these errors were encountered: