Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Jquery search in json

$(function() {
    var json = {
        "people": {
            "person": [{
                "name": "Peter",
                "age": 43,
                "sex": "male"},
            {
                "name": "Zara",
                "age": 65,
                "sex": "female"}]
        }
    };
    $.each(json.people.person, function(i, v) {
        if (v.name.search(new RegExp(/peter/i)) != -1) {
            alert(v.age);
            return;
        }
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript not empty array not string 
Javascript :: how to extract year from utc in javascript 
Javascript :: wait one second in javascript using async wait 
Javascript :: avascript sleep 1 second 
Javascript :: js load multiple images 
Javascript :: how to get mat input value on keyup javascript 
Javascript :: local storage size check 
Javascript :: react redirect to url 
Javascript :: replace all dashes to slashes using jquery in a string 
Javascript :: for each element in object 
Javascript :: string length jquery 
Javascript :: js do every x seconds 
Javascript :: js check proccess alive 
Javascript :: jquery selected option value 
Javascript :: javascript is valid json string 
Javascript :: nodemon package.json start 
Javascript :: asignar valselect2 js 
Javascript :: jquery modify style attribute 
Javascript :: scroll to div jquery 
Javascript :: move dom element to another parent 
Javascript :: add id to html element javascript 
Javascript :: regular expression to find a string between two characters 
Javascript :: npm express-session 
Javascript :: angular cli create component with module 
Javascript :: encodeurl in javascript 
Javascript :: how to use custom stylesheets express node 
Javascript :: how to check what browser you are using javascript 
Javascript :: javascript switch 
Javascript :: jest console.log 
Javascript :: js image on canvas 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =