ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java
changeset 60 939453361b2d
parent 54 0cc18086f731
child 73 f7e7223e94d4
     1.1 --- a/ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java	Wed May 01 06:59:55 2013 +0200
     1.2 +++ b/ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java	Fri May 03 10:27:06 2013 +0200
     1.3 @@ -21,6 +21,7 @@
     1.4  package org.apidesign.html.kofx;
     1.5  
     1.6  import java.io.IOException;
     1.7 +import java.io.InputStream;
     1.8  import java.io.InputStreamReader;
     1.9  import java.io.PushbackInputStream;
    1.10  import java.io.Reader;
    1.11 @@ -39,6 +40,7 @@
    1.12  import org.json.JSONException;
    1.13  import org.json.JSONObject;
    1.14  import org.json.JSONTokener;
    1.15 +import org.openide.util.Exceptions;
    1.16  
    1.17  /** This is an implementation package - just
    1.18   * include its JAR on classpath and use official {@link Context} API
    1.19 @@ -167,6 +169,16 @@
    1.20          }
    1.21      }
    1.22      
    1.23 +    public static Object parse(InputStream is) throws IOException {
    1.24 +        try {
    1.25 +            InputStreamReader r = new InputStreamReader(is, "UTF-8");
    1.26 +            JSONTokener t = new JSONTokener(r);
    1.27 +            return new JSONObject(t);
    1.28 +        } catch (JSONException ex) {
    1.29 +            throw new IOException(ex);
    1.30 +        }
    1.31 +    }
    1.32 +    
    1.33      private static String findBaseURL() {
    1.34          WebEngine eng = (WebEngine) System.getProperties().get("webEngine");
    1.35          return (String) eng.executeScript(