org.mozilla.javascript.json.JsonParser Java Examples

The following examples show how to use org.mozilla.javascript.json.JsonParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NativeJSON.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
private static Object parse(Context cx, Scriptable scope, String jtext) {
  try {
    return new JsonParser(cx, scope).parseValue(jtext);
  } catch (JsonParser.ParseException ex) {
    throw ScriptRuntime.constructError("SyntaxError", ex.getMessage());
  }
}
 
Example #2
Source File: NativeJSON.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private static Object parse(Context cx, Scriptable scope, String jtext) {
  try {
    return new JsonParser(cx, scope).parseValue(jtext);
  } catch (JsonParser.ParseException ex) {
    throw ScriptRuntime.constructError("SyntaxError", ex.getMessage());
  }
}
 
Example #3
Source File: RhinoStringToJson.java    From elasticshell with Apache License 2.0 5 votes vote down vote up
@Override
public Object stringToJson(String json) {
    Context context = Context.getCurrentContext();
    try {
        return new JsonParser(context, ScriptRuntime.getGlobal(context)).parseValue(json);
    } catch (JsonParser.ParseException e) {
        logger.error("Unable to create a json object from string {}", json, e);
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example #4
Source File: JsonParserTest.java    From rhino-android with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}
 
Example #5
Source File: JsonParserTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}