private byte[] getByteValue(final JsonNode binaryNode) throws SerDeException {
    try {
      BinaryEncoding binaryEncoding = getBinaryEncodingForNode(binaryNode);
      switch (binaryEncoding) {
      case RAWSTRING:
        final String byteText = binaryNode.asText();
        if (byteText == null) {
          return null;
        }
        return byteText.getBytes(StandardCharsets.UTF_8);
      case BASE64:
        return binaryNode.binaryValue();
      default:
        throw new SerDeException(
            "No such binary encoding: " + binaryEncoding);
      }
    } catch (IOException e) {
      throw new SerDeException("Error generating JSON binary type from record.",
          e);
    }
  }
A user may configure the encoding for binary data represented as text
within a JSON object. This method applies that encoding to the text.

@param binaryNode JSON Node containing the binary data
@return A byte array with the binary data
@throws SerDeException The SerDe is not configured correctly
serde/src/java/org/apache/hadoop/hive/serde2/json/HiveJsonReader.java