Click here to Skip to main content
15,063,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having one jsondata, which is nothing but an object array.

It looks like below:

JSONdata--> [0] - [universitycode]=10001,[cgpa]=8.3,[duration]=80hrs

[1] - [universitycode]=10002,[cgpa]=7.3,[duration]=80hrs
[2] - [universitycode]=10003,[cgpa]=9.3,[duration]=90hrs

Now I have to find which object has universitycode 10001.

Can you please provide the easiest way to find this?
Updated 24-Nov-10 1:51am
Dalek Dave 24-Nov-10 7:51am
Edited for Grammar and Readability.

1 solution

Take a look at this sample

function findIndexByKeyValue: finds "key" key inside "ob" object that equals "value" value
example: findIndexByKeyValue(students, 'name', "Jim");
object: students = [
   {name: 'John', age: 100, profession: 'Programmer'},
   {name: 'Jim', age: 50, profession: 'Carpenter'}
would find the index of "Jim" and return 1
function findIndexByKeyValue(obj, key, value)
    for (var i = 0; i < obj.length; i++) {
        if (obj[i][key] == value) {
            return i;
    return null;

Hope this helps or communicate regarding further query.

Please vote and Accept Answer if it Helped.
Kashsolai 25-Nov-10 0:18am
I dont want to put for loop here. Like server side Linq query,I need where statement, select statement etc. is there any plugin or extension??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900