@Test
  public void testSerializeBinaryData() throws Exception {
    Properties props = new Properties();
    props.setProperty(serdeConstants.LIST_COLUMNS, "name,content");
    props.setProperty(serdeConstants.LIST_COLUMN_TYPES, "string,binary");
    props.setProperty(serdeConstants.TIMESTAMP_FORMATS, "millis");

    final String jsonText = loadJson("single_pixel.json");

    JsonSerDe serde = new JsonSerDe();
    serde.initialize(new Configuration(), props, null, false);

    ObjectInspector oi = serde.getObjectInspector();

    final byte[] buf = Base64.getMimeDecoder()
        .decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAf"
            + "FcSJAAAADUlEQVR42mNUuXDhPwAFqQLFTWHXeAAAAABJRU5ErkJggg==");

    Object testObject =
        Arrays.asList(new Text("single_pixel.png"), new BytesWritable(buf));

    Object result = serde.serialize(testObject, oi);
    Text text = (Text) result;
    Assert.assertEquals(jsonText, text.toString());
  }
Test serializing a information about a file to JSON. The name of the file
is a "single_pixel.png" and the binary data of the PNG file are stored in
JSON. By default, the writer uses base-64 mime encoding.
serde/src/test/org/apache/hadoop/hive/serde2/TestJsonSerDe.java