class JsonCodec implements ContentCodec {

    @Override
    public byte[] valueToBytes(Object value,
                               Map<String, String> parameters) throws ContentCodecException {
        try {
            return getMapper().writeValueAsBytes(value);
        }
        catch (JsonProcessingException e) {
            throw new ContentCodecException("Failed to encode " + getMediaType() + ": " + e.toString());
        }
    }

}