Exemplo n.º 1
0
 private Object parseURL(URL url, Map params, String charset) {
   Reader reader = null;
   try {
     if (params == null || params.isEmpty()) {
       reader = ResourceGroovyMethods.newReader(url, charset);
     } else {
       reader = ResourceGroovyMethods.newReader(url, params, charset);
     }
     return parse(reader);
   } catch (IOException ioe) {
     throw new JsonException("Unable to process url: " + url.toString(), ioe);
   } finally {
     if (reader != null) {
       DefaultGroovyMethodsSupport.closeWithWarning(reader);
     }
   }
 }
Exemplo n.º 2
0
 private Object parseFile(File file, String charset) {
   Reader reader = null;
   try {
     if (charset == null || charset.length() == 0) {
       reader = ResourceGroovyMethods.newReader(file);
     } else {
       reader = ResourceGroovyMethods.newReader(file, charset);
     }
     return parse(reader);
   } catch (IOException ioe) {
     throw new JsonException("Unable to process file: " + file.getPath(), ioe);
   } finally {
     if (reader != null) {
       DefaultGroovyMethodsSupport.closeWithWarning(reader);
     }
   }
 }