jquery search in json get json data

Solutions on MaxInterview for jquery search in json get json data by the best coders in the world

showing results for - "jquery search in json get json data"
Francesco
25 May 2016
1$(function() {
2    var json = {
3        "people": {
4            "person": [{
5                "name": "Peter",
6                "age": 43,
7                "sex": "male"},
8            {
9                "name": "Zara",
10                "age": 65,
11                "sex": "female"}]
12        }
13    };
14    $.each(json.people.person, function(i, v) {
15        if (v.name.search(new RegExp(/peter/i)) != -1) {
16            alert(v.age);
17            return;
18        }
19    });
20});
21
Marwane
11 May 2019
1<!DOCTYPE html>
2<html>
3<head>
4<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
5<script>
6$(document).ready(function(){
7    $("button").click(function(){
8        $.getJSON("json1.json", function(result){
9            $.each(result, function(i, obj){
10                $("div").append(obj.first + " " + obj.last + " " + obj.desc + " " + "<br>");
11            });
12        });
13    });
14});
15</script>
16</head>
17<body>
18
19<button>Get JSON data</button>
20
21<div></div>
22
23</body>
24</html>