code: def _add_json_binary_field(b, serialized, field):
      '''' Set the given field to the given val (bytes) in the serialized
      dictionary.
      If the value isn't valid utf-8, we base64 encode it and use field+"64"
      as the field name.
      '''
      try:
          val = b.decode('utf-8')
          serialized[field] = val
      except UnicodeDecodeError:
          val = base64.b64encode(b).decode('utf-8')
          serialized[field + '64'] = vaf _add_json_binary_field(b, serialized, field):
      '''' Set the given field to the given val (bytes) in the serialized
      dictionary.
      If the value isn't valid utf-8, we base64 encode it and use field+"64"
      as the field name.
      '''
      try:
          val = b.decode('utf-8')
          serialized[field] = val
      except UnicodeDecodeError:
          val = base64.b64encode(b).decode('utf-8')
          serialized[field + '64'] = val
docs: Set the given field to the given val (bytes) in the serialized
      dictionary.
      If the value isn't valid utf-8, we base64 encode it and use field+"64"
      as the field name.