List of usage examples for com.mongodb.util JSONSerializers getStrict
public static ObjectSerializer getStrict()
From source file:com.biztweets.formatter.JSONResultHandler.java
License:Apache License
public String map(DBObject result) { return JSONSerializers.getStrict().serialize(result); }
From source file:com.edgytech.umongo.MongoUtils.java
License:Apache License
static ObjectSerializer getSerializer() { return JSONSerializers.getStrict(); }
From source file:org.bson.BasicBSONObject.java
License:Apache License
/** * Returns a JSON serialization of this object * * @return JSON serialization/*from w w w . j a v a2 s .c om*/ */ @Override public String toString() { return JSONSerializers.getStrict().serialize(this); }
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 . j a v a 2s .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 w w . ja va 2 s . com */ 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); }
From source file:org.vertx.mods.MongoUtil.java
License:Apache License
/** * Converts a DBObject to its Bson form and then encapsulates it in a JsonObject * @param dbObject the object to convert * @return the JsonObject representing the Bson MongoDB form * @throws java.lang.IllegalArgumentException if you pass in a null object *//* w w w.j a v a2 s . c om*/ public static JsonObject convertBsonToJson(DBObject dbObject) { if (dbObject == null) { throw new IllegalArgumentException("Cannot convert null to JsonObject"); } // Create JSON string from DBObject String serialize = JSONSerializers.getStrict().serialize(dbObject); // Convert to JsonObject HashMap<String, Object> jsonMap = Json.decodeValue(serialize, HashMap.class); return new JsonObject(jsonMap); }