Giacomo Balli profile picture
Giacomo Balli
Innovation consultant specializing in mobile strategy
Let's Chat

Find match in JSON Object

This code sample will allow you to look through an array of JSON objects and extract a specific property.

function findInJSON(el, key, id, toReturn) {
for (var q = 0; q < el.length; q++) {
if (el[q][key] == id) {
return el[q][toReturn];
return false;


- call findInJSON(el, key, id, toReturn);

- el is the array of JSON objects

- key is the property to be used when searching

- id is the value you are searching for

- toReturn is the property you want to be returned from the matching object

This snippet focuses on iOS development. Make sure to verify/adapt any vendor prefixes.

Back to main listing.

Published: Mon, 11 Jan 2016 02:55:00 +0000