JsonUtils.java
4.41 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.arellomobile.android.push.utils;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class JsonUtils
{
private static Object a(Object paramObject)
{
Object localObject;
if (paramObject == null) {
localObject = null;
}
for (;;)
{
return localObject;
localObject = paramObject;
if (!(paramObject instanceof JSONArray))
{
localObject = paramObject;
if (!(paramObject instanceof JSONObject)) {
try
{
if ((paramObject instanceof Collection)) {
return collectionToJson((Collection)paramObject);
}
if (paramObject.getClass().isArray()) {
return arrayToJson(paramObject);
}
if ((paramObject instanceof Map))
{
paramObject = mapToJson((Map)paramObject);
return paramObject;
}
localObject = paramObject;
if (!(paramObject instanceof Boolean))
{
localObject = paramObject;
if (!(paramObject instanceof Byte))
{
localObject = paramObject;
if (!(paramObject instanceof Character))
{
localObject = paramObject;
if (!(paramObject instanceof Double))
{
localObject = paramObject;
if (!(paramObject instanceof Float))
{
localObject = paramObject;
if (!(paramObject instanceof Integer))
{
localObject = paramObject;
if (!(paramObject instanceof Long))
{
localObject = paramObject;
if (!(paramObject instanceof Short))
{
localObject = paramObject;
if (!(paramObject instanceof String)) {
if (paramObject.getClass().getPackage().getName().startsWith("java."))
{
paramObject = paramObject.toString();
return paramObject;
}
}
}
}
}
}
}
}
}
}
}
catch (Exception paramObject) {}
}
}
}
return null;
}
public static JSONArray arrayToJson(Object paramObject)
throws JSONException
{
if (!paramObject.getClass().isArray()) {
throw new JSONException("Not a primitive data: " + paramObject.getClass());
}
int j = Array.getLength(paramObject);
JSONArray localJSONArray = new JSONArray();
int i = 0;
while (i < j)
{
localJSONArray.put(a(Array.get(paramObject, i)));
i += 1;
}
return localJSONArray;
}
public static JSONArray collectionToJson(Collection paramCollection)
{
JSONArray localJSONArray = new JSONArray();
if (paramCollection != null)
{
paramCollection = paramCollection.iterator();
while (paramCollection.hasNext()) {
localJSONArray.put(a(paramCollection.next()));
}
}
return localJSONArray;
}
public static JSONObject mapToJson(Map<?, ?> paramMap)
{
JSONObject localJSONObject = new JSONObject();
if (paramMap == null) {
return new JSONObject();
}
paramMap = paramMap.entrySet().iterator();
while (paramMap.hasNext())
{
Map.Entry localEntry = (Map.Entry)paramMap.next();
String str = (String)localEntry.getKey();
if (str == null) {
throw new NullPointerException("key == null");
}
try
{
localJSONObject.put(str, a(localEntry.getValue()));
}
catch (JSONException localJSONException)
{
localJSONException.printStackTrace();
}
}
return localJSONObject;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/arellomobile/android/push/utils/JsonUtils.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/