Example usage for org.json.simple.parser JSONParser reset

List of usage examples for org.json.simple.parser JSONParser reset

Introduction

In this page you can find the example usage for org.json.simple.parser JSONParser reset.

Prototype

public void reset() 

Source Link

Document

Reset the parser to the initial state without resetting the underlying reader.

Usage

From source file:hd3gtv.mydmam.db.orm.CassandraOrm.java

public JSONArray pullObjectsByIndexesToJSON(Expression... indexqueryexpressions)
        throws ConnectionException, ParseException {
    List<T> values = pullObjectsByIndexes(indexqueryexpressions);
    JSONArray ja = new JSONArray();
    JSONParser jp = new JSONParser();
    for (int pos = 0; pos < values.size(); pos++) {
        jp.reset();
        ja.add(jp.parse((new Gson()).toJson(values.get(pos))));
    }/*from www.  j a v a  2s. c  o m*/
    return ja;
}

From source file:hd3gtv.mydmam.db.orm.CassandraOrm.java

public JSONArray pullAllObjectsToJSON() throws Exception {
    prepareColumnlistnames();//from   w  w  w.  ja  va2 s  .c o m
    final JSONArray ja = new JSONArray();
    final JSONParser jp = new JSONParser();
    CassandraDb.allRowsReader(columnfamily, new AllRowsFoundRow() {
        public void onFoundRow(Row<String, String> row) throws Exception {
            jp.reset();
            ja.add(jp.parse((new Gson()).toJson(pullObject(row.getKey(), row.getColumns()))));
        }
    }, column_names);

    return ja;
}