-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJsonParserTest.java
78 lines (57 loc) · 2.09 KB
/
JsonParserTest.java
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
package main;
import dlab.JsonParser;
import dlab.JsonParser.OnValueObserver;
/**
* Created by Kishan Donga on 18-05-18
*/
public class JsonParserTest {
public static void main(String[] args) {
new JsonParser().addObserver(new OnValueObserver() {
@Override
public void onValueFound(String key, Object value) {
System.out.println(String.valueOf("Find By Key : " + value));
}
}).inFind(GetJson.strJson_4, "Dkey=[value]");
// Output :-
// Find By Key : New
// Find By Key : Open
// Find By Key : Close
new JsonParser().addObserver(new OnValueObserver() {
@Override
public void onValueFound(String key, Object value) {
System.out.println(String.valueOf("Find By Path : " + value.toString()));
}
}).inFind(GetJson.strJson_3, "Dpath=[menu/items/12/label]");
// Output :- Find By Path : Find...
new JsonParser().addObserver(new OnValueObserver() {
@Override
public void onValueFound(String key, Object value) {
System.out.println(String.valueOf("Find By Path : " + value.toString()));
}
}).inFind(GetJson.strJson_2, "Dpath=[No/1]");
// Output :- Find By Path : 1
new JsonParser().addObserver(new OnValueObserver() {
@Override
public void onValueFound(String key, Object value) {
new JsonParser().addObserver(new OnValueObserver() {
@Override
public void onValueFound(String key, Object value) {
System.out.println(String.valueOf("Find By Path : " + value.toString()));
}
}).inFind(value.toString(), "Dpath=[medicationsClasses/1/className/1/associatedDrug/1/name]");
}
}).inFind(GetJson.strJson_1, "Dpath=[problems/1/Diabetes/1/medications/1/]");
// Output :- Find By Path : asprin
new JsonParser().addObserver(new OnValueObserver() {
@Override
public void onValueFound(String key, Object value) {
System.out.println(String.valueOf("Find By Key : " + value));
}
}).inFind(GetJson.strJson_1, "Dkey=[name]");
// Output :-
// Find By Key : asprin
// Find By Key : somethingElse
// Find By Key : asprin
// Find By Key : somethingElse
}
}