在JSON响应中搜索关键字


Searching for Keyword in JSON response in php

这是我得到的JSON响应。我正在寻找的名称,生物,专业在这个响应使用php中的java脚本。使用javascript搜索代码

Array(
[contense] => Array
    (
        [0] => Array
            (
                [ref] => Array
                    (
                        [0] => 1
                        [1] => 2
                        [2] => 3
                        [3] => 4
                        [4] => 5
                        [5] => 6
                    )
                [name] => Array
                    (
                        [0] => James
                        [1] => Bob
                        [2] => Dan
                        [3] => Olive
                        [4] => Jess
                        [5] => Tim
                    )
                [specialism] => Array
                    (
                        [0] => 
                        [1] => 
                        [2] => 
                        [3] => 
                        [4] => 
                        [5] => 
                    )
                [bio] => Array
                    (
                        [0] => About me
                        [1] => About me
                        [2] => About me
                        [3] => About me
                        [4] => About me
                        [5] => About me
                    )
                [picture] => Array
                    (
                        [0] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-1.png
                        [1] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-2.png
                        [2] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-3.png
                        [3] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-4.png
                        [4] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-4.png
                        [5] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-4.png
                    )
            )
    )

)在搜索文本框中按下键进行搜索。

这是我的javascript代码

var xmlhttp = new XMLHttpRequest(); var url = "url"; 
xmlhttp.onreadystatechange=function() { 
           if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
                myFunction(xmlhttp.responseText); 
           }
         }xmlhttp.open("GET", url, true); xmlhttp.send(); function myFunction(response) {var arr = JSON.parse(response); //...code for serach }

使用下面的代码获取键

var keys = Object.getOwnPropertyNames ( data )  // where data is the JSON data

看到