Example #1
0
 private Scriptable parseJsonResource(Resource resource) throws IOException {
   JsonParser parser = new JsonParser(Context.getCurrentContext(), globalScope);
   try {
     Object result = parser.parseValue(resource.getContent());
     if (!(result instanceof Scriptable)) {
       throw new RuntimeException("Expected Object from package.json, got " + result);
     }
     return (Scriptable) result;
   } catch (JsonParser.ParseException px) {
     throw new RuntimeException(px);
   }
 }