List of usage examples for jdk.nashorn.internal.parser JSONParser JSONParser
public JSONParser(final String source, final Global global, final boolean dualFields)
From source file:capframework.http.core.ConfigFileParser.java
License:Apache License
void parse() { if (isConfigFileExist()) { try {/*from w ww .j a v a 2 s . 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(); } } }