Example usage for com.mongodb.util ObjectSerializer serialize

List of usage examples for com.mongodb.util ObjectSerializer serialize

Introduction

In this page you can find the example usage for com.mongodb.util ObjectSerializer serialize.

Prototype

String serialize(Object obj);

Source Link

Document

Serializes obj .

Usage

From source file:org.meta.api.ws.AbstractPluginWebServiceController.java

License:Open Source License

/**
 * Serialize as JSON the list of commands.
 *
 * @return a list of commands as JSON/*from w w  w.  jav a  2  s.  c o m*/
 */
public final String getJsonCommandList() {
    BasicBSONList list = new BasicBSONList();
    for (Iterator<String> i = lstCommands.keySet().iterator(); i.hasNext();) {
        String key = (String) i.next();
        list.add(key);
    }

    // Serialize BasicBSONList in JSON
    ObjectSerializer jsonSerializer = JSONSerializers.getStrict();
    return jsonSerializer.serialize(list);
}

From source file:org.meta.plugin.webservice.MetaWebServer.java

License:Open Source License

/**
 * <p>getPluginListAsJson</p>
 *
 * @return a plugin list as JSON/*w  ww.  j  ava  2s  .  c  om*/
 */
public String getPluginListAsJson() {
    BasicBSONList list = new BasicBSONList();
    for (Iterator<String> i = mapPlugins.keySet().iterator(); i.hasNext();) {
        String key = (String) i.next();
        list.add(key);
    }

    // Serialize BasicBSONList in JSON
    ObjectSerializer jsonSerializer = JSONSerializers.getStrict();
    return jsonSerializer.serialize(list);
}