@Override public void writeRawValue(String text) throws IOException { delegate.writeRawValue(text); }
@Override public void writeRawValue(char[] text, int offset, int len) throws IOException { delegate.writeRawValue(text, offset, len); }
@Override public void writeRawValue(String text, int offset, int len) throws IOException { delegate.writeRawValue(text, offset, len); }
protected void _serialize(JsonGenerator gen) throws IOException { if (_value instanceof SerializableString) { gen.writeRawValue((SerializableString) _value); } else { gen.writeRawValue(String.valueOf(_value)); } }
@Override public void serialize(T value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeRawValue(value.toString()); }
@Override public void writeRawValue(String text) throws IOException { delegate.writeRawValue(text); }
@Override public void writeRawValue(String text, int offset, int len) throws IOException { delegate.writeRawValue(text, offset, len); }
@Override public void writeRawValue(char[] text, int offset, int len) throws IOException { delegate.writeRawValue(text, offset, len); }
/** * Method similar to {@link #writeRawValue(String)}, but potentially more * efficient as it may be able to use pre-encoded content (similar to * {@link #writeRaw(SerializableString)}. * * @since 2.5 */ public void writeRawValue(SerializableString raw) throws IOException { writeRawValue(raw.getValue()); }
@Override public void serialize(Slice slice, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeRawValue(slice.toStringUtf8()); } }
/** * Method similar to {@link #writeRawValue(String)}, but potentially more * efficient as it may be able to use pre-encoded content (similar to * {@link #writeRaw(SerializableString)}. */ public void writeRawValue(SerializableString raw) throws IOException { writeRawValue(raw.getValue()); }
@Override public void serialize(TApplicationException value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeRawValue(writeThriftObjectAsTText(protocol -> { try { value.write(protocol); } catch (TException ex) { throw new IllegalArgumentException(ex); } })); } }
@Override public void serialize(TBase value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeRawValue(writeThriftObjectAsTText(protocol -> { try { value.write(protocol); } catch (TException ex) { throw new IllegalArgumentException(ex); } })); } }
@Override public void writeJsonValue(JsonGenerator jsonGenerator, Block block, int position, ConnectorSession session) throws IOException { if (block.isNull(position)) { jsonGenerator.writeNull(); } else { Slice value = JSON.getSlice(block, position); jsonGenerator.writeRawValue(value.toStringUtf8()); } } }
@Override public void serialize(PackedCoordinateSequence value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartArray(); for (int i = 0; i < value.size(); ++i) { jgen.writeStartArray(); for (int j = 0; j < value.getDimension(); j++) { double ordinate = value.getOrdinate(i, j); if (!Double.isNaN(ordinate)) { if (precision == -1) { jgen.writeObject(ordinate); } else { jgen.writeRawValue(String.format("%." + precision + "f", ordinate)); } } } jgen.writeEndArray(); } jgen.writeEndArray(); }
@Override public void serialize(WithGraph object, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { // FIXME: there is probably a simple way to automatically wire this up that I can't find // right now ObjectMapper mapper = SerializerUtils.getMapper(); SimpleModule module = SerializerUtils.getSerializerModule(); module.addSerializer(new VertexSerializer()); mapper.registerModule(module); //configuring jgen to just use the mapper doesn't actually work jgen.writeRawValue(mapper.writeValueAsString(object.getObject())); }
public static void writeValueToJSON(JsonGenerator g, boolean includeNullField, String key, Object value) throws IOException { if (value == null && !includeNullField) return; if (value instanceof ScriptObjectMirror) { try { String json = Scripting.stringify((ScriptObjectMirror) value); writeValueToJSON(g, includeNullField, key, new RawJSONString(json)); } catch (ScriptException e) { LOGGER.error("error stringifying json object:", e); } } else if (value instanceof List) { // sets come back from .asJSON as lists, and jackson can't deal with lists natively. List stringList = (List) value; g.writeArrayFieldStart(key); for (Object s : stringList) { g.writeObject(s); } g.writeEndArray(); } else if (value instanceof RawJSONString) { // JSON column type, using binlog-connector's serializers. g.writeFieldName(key); g.writeRawValue(((RawJSONString) value).json); } else { g.writeObjectField(key, value); } } }
@Override public void serialize(WithGraph object, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { // FIXME: there is probably a simple way to automatically wire this up that I can't find // right now ObjectMapper mapper = SerializerUtils.getMapper(); SimpleModule module = SerializerUtils.getSerializerModule(); module.addSerializer(new EdgeSerializer(object.getGraph())); mapper.registerModule(module); //configuring jgen to just use the mapper doesn't actually work jgen.writeRawValue(mapper.writeValueAsString(object.getObject())); }
@Override public void writeRawValue(String text) { try { generator.writeRawValue(text); } catch (IOException e) { throw new JsonIOException(e); } }
public static void serializeCol(JsonGenerator jgen, ColumnMetadataDescription colDescription, byte[] col) throws IOException { if (colDescription.hasDynamicColumns()) { DynamicColumnDescription dynMetadata = colDescription.getDynamicColumn(); NameMetadataDescription description = dynMetadata.getColumnNameDesc(); jgen.writeRawValue(description.renderToJson(col)); } else { Set<NamedColumnDescription> namedColumns = colDescription.getNamedColumns(); for (NamedColumnDescription description : namedColumns) { if (UnsignedBytes.lexicographicalComparator().compare(col, PtBytes.toCachedBytes(description.getShortName())) == 0) { jgen.writeString(description.getLongName()); return; } } throw new IllegalArgumentException( "Column " + BaseEncoding.base16().lowerCase().encode(col) + " is not a valid column."); } }