@Override public String encode(CodecRegistryProvider provider, boolean quoted) { return JSON.serialize(this.value); } }
/** * Returns a JSON serialization of this object * * @return JSON serialization */ @SuppressWarnings("deprecation") public String toString() { return com.mongodb.util.JSON.serialize(this); } }
@Override @SuppressWarnings("deprecation") public String toString() { return com.mongodb.util.JSON.serialize(this); }
@Override public String toString() { return "Timestamp.BSON(ts=" + JSON.serialize(ts) + ")"; }
/** * Returns a JSON serialization of this object * * @return JSON serialization */ @SuppressWarnings("deprecation") public String toString() { return com.mongodb.util.JSON.serialize(this); } }
private String getParameterWithIndex(List<Object> values, int index) { return JSON.serialize(values.get(index)); }
/** * <p>Serializes an object into its JSON form.</p> * * <p>This method delegates serialization to {@code JSONSerializers.getLegacy}</p> * * @param object object to serialize * @return String containing JSON form of the object * @see JSONSerializers#getLegacy() */ public static String serialize(final Object object) { StringBuilder buf = new StringBuilder(); serialize(object, buf); return buf.toString(); }
@Override public void saveFields(XContentBuilder builder) throws IOException { builder.field(MongoDBRiver.LAST_TIMESTAMP_FIELD, JSON.serialize(ts)); } }
@Override public String toString() { return "Timestamp.GTID(ts=" + JSON.serialize(ts) + ", gtid=" + JSONSerializers.getStrict().serialize(gtid) + ")"; }
/** * Serializes the given object into pseudo-JSON meaning it's trying to create a JSON representation as far as possible * but falling back to the given object's {@link Object#toString()} method if it's not serializable. Useful for * printing raw {@link Document}s containing complex values before actually converting them into Mongo native types. * * @param value * @return the serialized value or {@literal null}. */ @Nullable public static String serializeToJsonSafely(@Nullable Object value) { if (value == null) { return null; } try { return value instanceof Document ? ((Document) value).toJson() : JSON.serialize(value); } catch (Exception e) { if (value instanceof Collection) { return toString((Collection<?>) value); } else if (value instanceof Map) { return toString((Map<?, ?>) value); } else { return String.format("{ \"$java\" : %s }", value.toString()); } } }
@Override public void saveFields(XContentBuilder builder) throws IOException { builder.field(MongoDBRiver.LAST_TIMESTAMP_FIELD, JSON.serialize(ts)); builder.field(MongoDBRiver.LAST_GTID_FIELD, JSONSerializers.getStrict().serialize(gtid)); } }
/** * Returns the serialized value to be used for the given {@link ParameterBinding}. * * @param accessor must not be {@literal null}. * @param parameters * @param binding must not be {@literal null}. * @return */ @SuppressWarnings("unchecked") private String getParameterValueForBinding(MongoParameterAccessor accessor, MongoParameters parameters, ParameterBinding binding) { Object value = binding.isExpression() ? evaluateExpression(binding.getExpression(), parameters, accessor.getValues()) : accessor.getBindableValue(binding.getParameterIndex()); if (value instanceof String && binding.isQuoted()) { if (binding.isExpression() && ((String) value).startsWith("{")) { return (String) value; } return binding.isExpression() ? JSON.serialize(value) : QuotedString.unquote(JSON.serialize(value)); } return EncodableValue.create(value).encode(codecRegistryProvider, binding.isQuoted()); }
@Override public String encode(CodecRegistryProvider provider, boolean quoted) { return JSON.serialize(this.value); } }
@Override public void storeSchema(SimpleFeatureType schema) throws IOException { if (schema == null) { return; } File schemaFile = schemaFile(schema.getTypeName()); BufferedWriter writer = new BufferedWriter(new FileWriter(schemaFile)); try { writer.write(JSON.serialize(FeatureTypeDBObject.convert(schema))); } finally { writer.close(); } }
/** * Serializes the given object into pseudo-JSON meaning it's trying to create a JSON representation as far as possible * but falling back to the given object's {@link Object#toString()} method if it's not serializable. Useful for * printing raw {@link Document}s containing complex values before actually converting them into Mongo native types. * * @param value * @return the serialized value or {@literal null}. */ @Nullable public static String serializeToJsonSafely(@Nullable Object value) { if (value == null) { return null; } try { return value instanceof Document ? ((Document) value).toJson() : JSON.serialize(value); } catch (Exception e) { if (value instanceof Collection) { return toString((Collection<?>) value); } else if (value instanceof Map) { return toString((Map<?, ?>) value); } else { return String.format("{ \"$java\" : %s }", value.toString()); } } }
/** * Returns the serialized value to be used for the given {@link ParameterBinding}. * * @param accessor must not be {@literal null}. * @param parameters * @param binding must not be {@literal null}. * @return */ @SuppressWarnings("unchecked") private String getParameterValueForBinding(MongoParameterAccessor accessor, MongoParameters parameters, ParameterBinding binding) { Object value = binding.isExpression() ? evaluateExpression(binding.getExpression(), parameters, accessor.getValues()) : accessor.getBindableValue(binding.getParameterIndex()); if (value instanceof String && binding.isQuoted()) { if (binding.isExpression() && ((String) value).startsWith("{")) { return (String) value; } return binding.isExpression() ? JSON.serialize(value) : QuotedString.unquote(JSON.serialize(value)); } return EncodableValue.create(value).encode(codecRegistryProvider, binding.isQuoted()); }
/** * Returns a JSON serialization of this object * * @return JSON serialization */ @SuppressWarnings("deprecation") public String toString() { return com.mongodb.util.JSON.serialize(this); } }
@Override @SuppressWarnings("deprecation") public String toString() { return com.mongodb.util.JSON.serialize(this); }
@Override public String map(DBObject result) { return JSON.serialize(result); } });
public String toJSON() { BasicDBList returnVal = new BasicDBList(); for (CollectionSplitterConf conf : collectionSplitters) { returnVal.add(new BasicDBObject(conf.toConfigMap())); } return JSON.serialize(returnVal); }