@Override public void serialize( LeafDataNode leafDataNode, JsonGenerator generator, SerializerProvider provider) throws IOException, JsonProcessingException { try { switch (leafDataNode.getLeafType()) { case BIG_DECIMAL: generator.writeNumber(leafDataNode.getBigDecimal(null)); break; case BIG_INTEGER: generator.writeNumber(leafDataNode.getBigInteger(null)); break; case BINARY: generator.writeBinary(leafDataNode.getBytes(null)); break; case BOOLEAN: generator.writeBoolean(leafDataNode.getBoolean(false)); break; case DOUBLE: generator.writeNumber(leafDataNode.getDouble(0.0)); break; case LONG: generator.writeNumber(leafDataNode.getLong(0)); break; case STRING: generator.writeString(leafDataNode.getString(null)); break; default: assert false; break; } } catch (BigDBException e) { assert false; } }
@Override public void serializeWithType( byte[] value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { typeSer.writeTypePrefixForScalar(value, g); g.writeBinary(provider.getConfig().getBase64Variant(), value, 0, value.length); typeSer.writeTypeSuffixForScalar(value, g); }
@Override public void serialize( final BufferedImage value, final JsonGenerator gen, final SerializerProvider sP) throws IOException, JsonProcessingException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(value, "png", baos); gen.writeBinary(baos.toByteArray()); }
@Override public void serialize(byte[] value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeBinary(provider.getConfig().getBase64Variant(), value, 0, value.length); }