Java 类org.mozilla.javascript.json.JsonParser 实例源码

项目:jshint-for-netbeans    文件:JSHint.java   
@NbBundle.Messages({
    "LBL_InvalidRC=Invalid .jshintrc",
    "# {0} - Linted JavaScript file",
    "# {1} - RC file",
    "DESC_InvalidRC=File {0} was linted with default configuration because its related {1} is not valid json",
    "ICON_InvalidRC="
})
private Scriptable getConfig(Context cx, FileObject fo) throws ParseException, IOException {
    JsonParser parser = new JsonParser(cx, scope);
    FileObject config = findConfig(fo);

    if (config == null) {
        return cx.newObject(scope);
    }

    String json = config.asText();

    try {
        return (Scriptable) parser.parseValue(json);
    }
    catch (ParseException ex) {
        JTextArea text = new JTextArea(Bundle.DESC_InvalidRC(fo.getPath(), config.getPath()));
        NotificationDisplayer.getDefault().notify(Bundle.LBL_InvalidRC(), new ImageIcon(Bundle.ICON_InvalidRC()), text, text, NotificationDisplayer.Priority.NORMAL);
        return cx.newObject(scope);
    }
}
项目:HL4A    文件:NativeJSON.java   
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());
  }
}
项目:whackpad    文件:NativeJSON.java   
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());
  } 
}
项目:TEI-Completer    文件:JSONTransformer.java   
private Object parseJson(final Context context, final Scriptable scope, final InputStream json) throws IOException, TransformationException {
    try {
        final char buf[] = new char[4096];
        int read = -1;
        final StringBuilder builder = new StringBuilder();
        try (final Reader reader = new InputStreamReader(json, UTF_8)) {
            while ((read = reader.read(buf)) > -1) {
                builder.append(buf, 0, read);
            }
        }
        return new JsonParser(context, scope).parseValue(builder.toString());
    } catch(final JsonParser.ParseException e) {
        throw new TransformationException("Unable to parse JSON", e);
    }
}
项目:TaleCraft    文件:NativeJSON.java   
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());
  }
}
项目:code404    文件:NativeJSON.java   
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());
  }
}
项目:rhino-jscover    文件:NativeJSON.java   
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());
  }
}
项目:LoboEvolution    文件:NativeJSON.java   
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());
  }
}
项目:astor    文件:NativeJSON.java   
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());
  }
}
项目:Rhino-Prov-Mod    文件:NativeJSON.java   
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());
  }
}
项目:android-js    文件:NativeJSON.java   
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());
  }
}
项目:minium    文件:RhinoEngine.java   
@Override
public void putJson(final String varName, final String json) {
    runWithContext(new RhinoCallable<Object, RuntimeException>() {
        @Override
        protected Object doCall(Context cx, Scriptable scope) throws RuntimeException {
            try {
                Object obj = new JsonParser(cx, scope).parseValue(json);
                scope.put(varName, scope, obj);
                return null;
            } catch (ParseException e) {
                throw Throwables.propagate(e);
            }
        }
    });
}
项目:minium    文件:RhinoWebModules.java   
@Override
public Object coerce(Object obj, Type type) {
    Context cx = Context.enter();
    try {
        if (obj instanceof String) {
            return new JsonParser(cx, cx.initStandardObjects()).parseValue((String) obj);
        }
        return obj;
    } catch (ParseException e) {
        // just assume it's actually a string
        return obj;
    }
}
项目:closure-compiler-old    文件:NativeJSON.java   
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());
  }
}
项目:elasticshell    文件:RhinoStringToJson.java   
@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);
    }
}
项目:closure-compiler-copy    文件:NativeJSON.java   
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());
  }
}
项目:whackpad    文件:JsonParserTest.java   
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}
项目:rhino-android    文件:JsonParserTest.java   
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}
项目:code404    文件:JsonParserTest.java   
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}
项目:rhino-jscover    文件:JsonParserTest.java   
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}
项目:astor    文件:JsonParserTest.java   
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}
项目:Rhino-Prov-Mod    文件:JsonParserTest.java   
@Before
public void setUp() {
    cx = Context.enter();
    parser = new JsonParser(cx, cx.initStandardObjects());
}