- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJSONUtils.java
More file actions
Latest commit
42 lines (37 loc) · 1.16 KB
/
Copy pathJSONUtils.java
File metadata and controls
42 lines (37 loc) · 1.16 KB
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
packagecom.jsonsync;
importcom.jsonsync.JSONSyncRuntimeException;
importcom.jsonsync.utils.json.JSONArray;
importcom.jsonsync.utils.json.JSONException;
importcom.jsonsync.utils.json.JSONObject;
/**
*
* @author Arnaud CAVAILHEZ
*/
classJSONUtils {
publicstaticintindexOfObjectInJSONArray(Objecto, JSONArrayarray) {
for (inti = 0; i < array.length(); i++) {
try {
if (array.get(i).equals(o)) {
returni;
}
} catch (JSONExceptionex) {
thrownewJSONSyncRuntimeException("#indexOfObjectInJSONArray failed ", ex);
}
}
return -1;
}
publicstaticJSONArraycopyJSONArray(JSONArrayarray) {
try {
returnnewJSONArray(array.toString());
} catch (JSONExceptionex) {
thrownewJSONSyncRuntimeException("Could not copy JSON", ex);
}
}
publicstaticJSONObjectcopyJSON(JSONObjectjson) {
try {
returnnewJSONObject(json.toString());
} catch (JSONExceptionex) {
thrownewJSONSyncRuntimeException("Could not copy JSON", ex);
}
}
}