Package org.json

Examples of org.json.JSONTokener.nextValue()


      }
     
      sw.flush();
     
      JSONTokener tokener = new JSONTokener(sw.toString());
      result = tokener.nextValue();
     
    } catch (Exception e) {
      throw new Exception("Error while reading file: "+file.getName(), e);
     
    } finally {
View Full Code Here


    static protected ProjectMetadata loadFromFile(File metadataFile) throws Exception {
        FileReader reader = new FileReader(metadataFile);
        try {
            JSONTokener tokener = new JSONTokener(reader);
            JSONObject obj = (JSONObject) tokener.nextValue();

            return ProjectMetadata.loadFromJSON(obj);
        } finally {
            reader.close();
        }
View Full Code Here

       
        String columnName = request.getParameter("columnName");
        String configString = request.getParameter("config");
       
        JSONTokener t = new JSONTokener(configString);
        JSONObject config = (JSONObject) t.nextValue();
       
        return new ReconOperation(engineConfig, columnName, ReconConfig.reconstruct(config));
    }
}
View Full Code Here

        if (file.exists() || file.canRead()) {
            FileReader reader = null;
            try {
                reader = new FileReader(file);
                JSONTokener tokener = new JSONTokener(reader);
                JSONObject obj = (JSONObject) tokener.nextValue();

                JSONArray a = obj.getJSONArray("projectIDs");
                int count = a.length();
                for (int i = 0; i < count; i++) {
                    long id = a.getLong(i);
View Full Code Here

        }
    }

    static public JSONArray evaluateJsonStringToArray(String s) throws JSONException {
        JSONTokener t = new JSONTokener(s);
        Object o = t.nextValue();
        if (o instanceof JSONArray) {
            return (JSONArray) o;
        } else {
            throw new JSONException(s + " couldn't be parsed as JSON array");
        }
View Full Code Here

                    List<Serializable> tuple = new ArrayList<Serializable>(valueCount);
                    for (int r = 0; r < valueCount; r++) {
                        line = reader.readLine();
                       
                        JSONTokener t = new JSONTokener(line);
                        Object o = t.nextValue();
                       
                        tuple.add((o != JSONObject.NULL) ? (Serializable) o : null);
                    }
                   
                    tuples.add(tuple);
View Full Code Here

    static public JSONObject evaluateJsonStringToObject(String s) throws JSONException {
        if( s == null ) {
            throw new IllegalArgumentException("parameter 's' should not be null");
        }
        JSONTokener t = new JSONTokener(s);
        Object o = t.nextValue();
        if (o instanceof JSONObject) {
            return (JSONObject) o;
        } else {
            throw new JSONException(s + " couldn't be parsed as JSON object");
        }
View Full Code Here

    Object fromJSON(String s) throws UnmarshallException {
        JSONTokener tok = new JSONTokener(s);
        Object json;
        try {
            json = tok.nextValue();
        } catch (ParseException e) {
            throw new UnmarshallException("couldn't parse JSON");
        }
        SerializerState state = new SerializerState();
        return unmarshall(state, null, json);
View Full Code Here

  private static void processJSON(File file, MapReduceDriver<Writable, Text, Text, Text, Text, Text> mapReduceDriver) throws JSONException, FileNotFoundException {
    JSONTokener tokener = new JSONTokener(new FileInputStream(file));
    char c = tokener.nextClean();
    if (c == '[') {
      while (true) {
        Object o = tokener.nextValue();
        mapReduceDriver.addInput(new BytesWritable(), new Text(o.toString()));
        char tmp = tokener.nextClean();
        if (tmp == ']')
          break;
      }
View Full Code Here

    PrintWriter pw = new PrintWriter(fsDataOutputStream);
    pw.println("[");
    tokener.nextClean();
    char tmp = '[';
    while(tmp != ']') {
      JSONObject obj = (JSONObject) tokener.nextValue();
      processJSONObject(obj);
      pw.println(obj.toString(4));
      tmp = tokener.nextClean();
      if (tmp != ']') {
        pw.println(",");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.