Skip to content

Instantly share code, notes, and snippets.

View hijaren's full-sized avatar
👽
beep boop beep

Jann Ibay hijaren

👽
beep boop beep
  • Chicago
View GitHub Profile
@iwek
iwek / find-in-json.js
Created October 20, 2012 21:43
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //