List of usage examples for jdk.nashorn.internal.parser JSONParser parse
public Object parse()
From source file:capframework.http.core.ConfigFileParser.java
License:Apache License
void parse() { if (isConfigFileExist()) { try {/*from www .j ava 2s .c o m*/ FileInputStream inputStream = new FileInputStream(file); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); int len; byte[] buffer = new byte[1024]; while ((len = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, len); } String src = outputStream.toString(); Context context = new Context(new Options("cap"), new ErrorManager(), loader); JSONParser jsonParser = new JSONParser(src, new Global(context), true); json = (JD) jsonParser.parse(); configs = (JD) json.get("ApplicationConfig"); resources = (JD) json.get("ResourceMapping"); errors = (NativeArray) json.get("ErrorHandlerMapping"); } catch (Exception e) { e.printStackTrace(); } } }
From source file:edu.brown.cs.bubbles.nobase.NobaseNashorn.java
License:Open Source License
/********************************************************************************/ @Override/*from www .java2s.c o m*/ public ISemanticData parse(NobaseProject proj, NobaseFile fd, boolean lib) { Source src = new Source(fd.getFileName(), fd.getContents()); Options opts = new Options("nashorn"); PrintWriter pw = new PrintWriter(new StringWriter()); ScriptEnvironment env = new ScriptEnvironment(opts, pw, pw); DeferredErrorManager em = new DeferredErrorManager(fd); if (fd.getFileName().endsWith(".json")) { JSONParser jsonparse = new JSONParser(src, em); Node nd = jsonparse.parse(); if (do_debug) { System.err.println("WORKING ON " + fd.getFileName()); try { ASTWriter pv = new ASTWriter(nd); System.err.println("PARSE: " + pv.toString()); } catch (Throwable t) { } } return null; } Parser parser = new Parser(env, src, em); FunctionNode fn = parser.parse(); if (fn == null) { NobaseMain.logE("Problem parsing " + fd.getFileName()); return null; } if (do_debug) { System.err.println("WORKING ON " + fd.getFileName()); try { ASTWriter pv = new ASTWriter(fn); System.err.println("PARSE: " + pv.toString()); } catch (Throwable t) { } } ParseData rslt = new ParseData(proj, fd, em, fn.getBody(), lib); if (do_debug) { System.err.println("RESULT: " + rslt.getRootNode().dumpTree(fd)); } return rslt; }
From source file:vkfriendsgraph.VK_JSONParser.java
public VK_JSONParser(JSONParser in) { Node node = in.parse(); //Event event; }