import java.util.Hashtable;
import java.util.Map;
-import javajs.J2SIgnoreImport;
-
-
/**
* a very simple JSON parser for JSON objects that are compatible with JavaScript
* @author Bob Hanson
*
*/
-@J2SIgnoreImport({ HashMap.class })
public class JSJSONParser {
private String str;
* Could return Integer, Float, Boolean, String, Map<String, Object>, Lst<Object>, or null
*
* @param str
+ * @param asHashTable
* @return a object equivalent to the JSON string str
*
*/
- public Object parse(String str) {
+ public Object parse(String str, boolean asHashTable) {
index = 0;
+ this.asHashTable = asHashTable;
this.str = str;
len = str.length();
return getValue(false);
if (isKey && c == 0)
throw new JSONException("invalid key");
- String string = str.substring(i, index);
+ String string = str.substring(i, index).trim();
// check for the only valid simple words: true, false, null (lower case)
// and in this case, only for
}
}
// only numbers from here on:
-
c = string.charAt(0);
if (c >= '0' && c <= '9' || c == '-')
try {
switch (getChar()) {
case ']':
return l;
- case 0:
+ case '\0':
throw new JSONException("invalid array");
}
returnChar();