private BinaryEncoding getBinaryEncodingForNode(JsonNode binaryNode) {
    String jsonValue = binaryNode.textValue();

    if (jsonValue == null || jsonValue.length() % 4 != 0 || !BASE64_PATTERN.matcher(jsonValue).matches()) {
      return BinaryEncoding.RAWSTRING;
    }

    return BinaryEncoding.BASE64;
  }
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