diff options
Diffstat (limited to 'src/utility.js')
-rw-r--r-- | src/utility.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/utility.js b/src/utility.js index 2cc2408c..0be6e598 100644 --- a/src/utility.js +++ b/src/utility.js @@ -95,10 +95,20 @@ function searchable() { } function walkJSON(item, func) { - func(item); - for (x in item) { - if (typeof item[x] === 'object') { - walkJSON(item[x], func); + if (item.length) { + for (var x = 0; x < item.length; x++) { + var y = item[x]; + if (y && typeof y === 'object') { + walkJSON(y, func); + } + } + } else { + func(item); + for (x in item) { + var y = item[x]; + if (y && typeof y === 'object') { + walkJSON(y, func); + } } } } |