Queries about JSON Jquery

1

I obtained data from an SQL query with AJAX, and in JQuery I get the results in the following way:

 var Data = $.parseJSON(result.d);

 var datos = Data.Resultados; // .Resultados es el nombre de mi tabla con los resultados de SQL

Is it possible with JQuery to make queries about that JSON?

NOTE: I've tried .filter but nothing works = (

var aux = Data.filter(function (i,n){
        return n.Id== "0001";
    });
    
asked by EriK 22.08.2017 в 17:32
source

1 answer

1

If you want to make queries against your JSON you can use json-query .

Example

jsonQuery('people[country=ES].name', { data: Data })

But I think it would be better if you made the filtering and mapping of your data yourself, for example:

const data = [{ age: 10 }, { age: 5 }, { age: 20 }, { age: 15 }, { age: 30 }];

const filtrados = data.filter(v => v.age > 17); // [{age:20}, {age:30}]
const mapeados = data.map(v => { age: v.age + 1 });
    
answered by 22.08.2017 в 17:44