1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
package org.json.simple; |
6 |
|
|
7 |
|
import java.io.IOException; |
8 |
|
import java.io.StringWriter; |
9 |
|
import java.io.Writer; |
10 |
|
import java.util.HashMap; |
11 |
|
import java.util.Iterator; |
12 |
|
import java.util.Map; |
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
@author |
18 |
|
|
|
|
| 3.8% |
Uncovered Elements: 51 (53) |
Complexity: 14 |
Complexity Density: 0.39 |
|
19 |
|
public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAware{ |
20 |
|
|
21 |
|
private static final long serialVersionUID = -503443796854799292L; |
22 |
|
|
23 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
24 |
11191 |
public JSONObject() {... |
25 |
11191 |
super(); |
26 |
|
} |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@param |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
0 |
public JSONObject(Map map) {... |
35 |
0 |
super(map); |
36 |
|
} |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@see |
44 |
|
|
45 |
|
@param |
46 |
|
@param |
47 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 4 |
Complexity Density: 0.24 |
|
48 |
0 |
public static void writeJSONString(Map map, Writer out) throws IOException {... |
49 |
0 |
if(map == null){ |
50 |
0 |
out.write("null"); |
51 |
0 |
return; |
52 |
|
} |
53 |
|
|
54 |
0 |
boolean first = true; |
55 |
0 |
Iterator iter=map.entrySet().iterator(); |
56 |
|
|
57 |
0 |
out.write('{'); |
58 |
0 |
while(iter.hasNext()){ |
59 |
0 |
if(first) |
60 |
0 |
first = false; |
61 |
|
else |
62 |
0 |
out.write(','); |
63 |
0 |
Map.Entry entry=(Map.Entry)iter.next(); |
64 |
0 |
out.write('\"'); |
65 |
0 |
out.write(escape(String.valueOf(entry.getKey()))); |
66 |
0 |
out.write('\"'); |
67 |
0 |
out.write(':'); |
68 |
0 |
JSONValue.writeJSONString(entry.getValue(), out); |
69 |
|
} |
70 |
0 |
out.write('}'); |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
0 |
public void writeJSONString(Writer out) throws IOException{... |
74 |
0 |
writeJSONString(this, out); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@see |
82 |
|
|
83 |
|
@param |
84 |
|
@return |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
86 |
0 |
public static String toJSONString(Map map){... |
87 |
0 |
final StringWriter writer = new StringWriter(); |
88 |
|
|
89 |
0 |
try { |
90 |
0 |
writeJSONString(map, writer); |
91 |
0 |
return writer.toString(); |
92 |
|
} catch (IOException e) { |
93 |
|
|
94 |
0 |
throw new RuntimeException(e); |
95 |
|
} |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0 |
public String toJSONString(){... |
99 |
0 |
return toJSONString(this); |
100 |
|
} |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0 |
public String toString(){... |
103 |
0 |
return toJSONString(); |
104 |
|
} |
105 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
106 |
0 |
public static String toString(String key,Object value){... |
107 |
0 |
StringBuffer sb = new StringBuffer(); |
108 |
0 |
sb.append('\"'); |
109 |
0 |
if(key == null) |
110 |
0 |
sb.append("null"); |
111 |
|
else |
112 |
0 |
JSONValue.escape(key, sb); |
113 |
0 |
sb.append('\"').append(':'); |
114 |
|
|
115 |
0 |
sb.append(JSONValue.toJSONString(value)); |
116 |
|
|
117 |
0 |
return sb.toString(); |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
@see |
125 |
|
|
126 |
|
@param |
127 |
|
@return |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0 |
public static String escape(String s){... |
130 |
0 |
return JSONValue.escape(s); |
131 |
|
} |
132 |
|
} |