Example usage for com.mongodb.util JSON parse

List of usage examples for com.mongodb.util JSON parse

Introduction

In this page you can find the example usage for com.mongodb.util JSON parse.

Prototype

public static Object parse(final String jsonString) 

Source Link

Document

Parses a JSON string and returns a corresponding Java object.

Usage

From source file:org.cbioportal.genome_nexus.annotation.util.Transformer.java

License:Open Source License

/**
 * Transforms the given jsonString into a list of DBObject instances.
 *
 * @param jsonString    json string//from  w  w w.  java  2  s .co  m
 * @return List of DBObject instances
 */
public static List<DBObject> convertToDbObject(String jsonString) {
    List<DBObject> dbObjects = new ArrayList<>();
    DBObject dbObject = (DBObject) JSON.parse(jsonString);

    // if it is a list, just add all into the list
    if (dbObject instanceof List) {
        for (Object obj : ((List) dbObject)) {
            dbObjects.add((DBObject) obj);
        }
    } else {
        dbObjects.add(dbObject);
    }

    return dbObjects;
}

From source file:org.cbioportal.session_service.domain.Session.java

License:Open Source License

public void setData(String data) {
    this.data = JSON.parse(data);
    // JSON.serialize it so that formatting is the same if we test later
    this.checksum = DigestUtils.md5DigestAsHex(JSON.serialize(this.data).getBytes());
}

From source file:org.chimi.s4s.metainfo.mongo.MongoMetaInfoDao.java

License:Apache License

/**
 * @param metadata
 * @return
 */
private DBObject getDbObject(MongoFileMetadata metadata) {
    DBObject dbObject = (DBObject) JSON.parse(metadata.toString());
    return dbObject;
}

From source file:org.cleaner.mongo.FindDuplicatesByMd5.java

License:Open Source License

@SuppressWarnings("unchecked")
private List<Document> getPipeline() {
    List<Document> pipeline = new ArrayList<>();

    pipeline.add(new Document((Map<String, Object>) JSON.parse(GROUP_JSON)));
    pipeline.add(new Document((Map<String, Object>) JSON.parse(MATCH_JSON)));

    return pipeline;
}

From source file:org.codinjutsu.tools.mongo.model.MongoQueryOptions.java

License:Apache License

public void setOperations(String aggregateQuery) {
    operations.clear();/* w w w  .j  ava  2  s. co m*/
    BasicDBList operations = (BasicDBList) JSON.parse(aggregateQuery);
    this.operations.addAll(operations);
}

From source file:org.codinjutsu.tools.mongo.model.MongoQueryOptions.java

License:Apache License

public void setFilter(String query) {
    if (!StringUtils.isBlank(query)) {
        filter = (DBObject) JSON.parse(query);
    }
}

From source file:org.codinjutsu.tools.mongo.model.MongoQueryOptions.java

License:Apache License

public void setProjection(String query) {
    if (!StringUtils.isBlank(query)) {
        projection = (DBObject) JSON.parse(query);
    }
}

From source file:org.codinjutsu.tools.mongo.model.MongoQueryOptions.java

License:Apache License

public void setSort(String query) {
    if (!StringUtils.isBlank(query)) {
        sort = (DBObject) JSON.parse(query);
    }
}

From source file:org.codinjutsu.tools.nosql.mongo.model.MongoQueryOptions.java

License:Apache License

public void setFilter(String query) {
    if (!StringUtils.isBlank(query)) {
        filter = (Bson) JSON.parse(query);
    }
}

From source file:org.codinjutsu.tools.nosql.mongo.model.MongoQueryOptions.java

License:Apache License

public void setProjection(String query) {
    if (!StringUtils.isBlank(query)) {
        projection = (Bson) JSON.parse(query);
    }
}