Skip to content

Commit 014119c

Browse files
hansonrhansonr
authored andcommitted
JSON reader fix for String reader
1 parent 6be7ecb commit 014119c

File tree

1 file changed

+9
-3
lines changed
  • sources/net.sf.j2s.java.core/src/swingjs/json

1 file changed

+9
-3
lines changed

sources/net.sf.j2s.java.core/src/swingjs/json/JSON.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ public static Object parse(String json) {
103103
}
104104

105105
public static Object parse(Reader br) {
106-
return ((JSONReader) br).data;
106+
if (br instanceof JSONReader)
107+
return ((JSONReader) br).data;
108+
InputStream is = /** @j2sNative br.$in || */null;
109+
return parse(is);
107110
}
108111

109112
/**
@@ -164,11 +167,14 @@ public static class JSONReader extends BufferedReader {
164167
Object data;
165168

166169
public JSONReader(InputStream in) {
167-
super((Reader) (Object) in);
170+
super((Reader) (Object) "");
168171
// could be buffered
169172
data = toObject(/** @j2sNative $in._ajaxData || $in.$in && $in.$in._ajaxData || */
170173
null);
171-
174+
if (data == null) {
175+
String json = (/** @j2sNative $in.str || $in.$in && $in.$in.str || */null);
176+
data = toObject(JSUtil.parseJSONRaw(json));
177+
}
172178
}
173179

174180
public JSONReader(Reader in) {

0 commit comments

Comments
 (0)