-
Notifications
You must be signed in to change notification settings - Fork 664
How to traverse a complex JSON doc with javascript and extract named values
Andrey Gershun edited this page May 25, 2015
·
1 revision
It has a specific problem to solve, extracting a named value from Json, I need some javascript to traverse reasonably complex json with nested objects and arrays, and extract values. Example json is
var data = {
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": {
"filters": [
{
"terms": {
"ACCOUNT_NUMBER": [
"37846589",
"37846540"
]
}
}
]
}
}
}
}
};
You can do it with AlaSQL SEARCH operator:
var res = alasql('SEARCH /+ACCOUNT_NUMBER/ FROM ?', [data]);
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo