-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
101 lines (91 loc) · 2.32 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<html>
<head>
<title>JsonPath tests</title>
<script src="http://jsonpath.googlecode.com/svn/trunk/src/js/jsonpath.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
var o = { "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
//res1 = jsonPath(o, "$..author").toJSONString(),
//res2 = jsonPath(o, "$..author", {resultType:"PATH"}).toJSONString();
//alert(res1)
$.ajaxSetup({ cache: false });
$(document).ready(function() {
//$("#json_string").text(o);
$("#run_btn").click(function(){
query = $("#query").val()
//alert(query)
res = jsonPath(o, query)
$("#result").val(JSON.stringify(res))
})
});
</script>
</head>
<body>
<pre id="json_string">
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
</pre>
<input style="width:600px;" type="text" id="query" value="$..author"></text>
<input type="submit" id="run_btn" value="Run"><br>
<textarea id="result" cols="100" rows="10"></textarea>
</body>
</html>