def METHOD_NAME(obj, with_type=False):
  """For internal use only; no backwards-compatibility guarantees.
  Converts Python objects into extra_types.JsonValue objects.
  Args:
    obj: Python object to be converted. Can be :data:`None`.
    with_type: If true then the basic types (``bytes``, ``unicode``, ``int``,
      ``float``, ``bool``) will be wrapped in ``@type:value`` dictionaries.
      Otherwise the straight value is encoded into a ``JsonValue``.
  Returns:
    A ``JsonValue`` object using ``JsonValue``, ``JsonArray`` and ``JsonObject``
    types for the corresponding values, lists, or dictionaries.
  Raises:
    TypeError: if the Python object contains a type that is not
      supported.
  The types supported are ``str``, ``bool``, ``list``, ``tuple``, ``dict``, and
  ``None``. The Dataflow API requires JsonValue(s) in many places, and it is
  quite convenient to be able to specify these hierarchical objects using
  Python syntax.
  """
  if obj is None:
    return extra_types.JsonValue(is_null=True)
  elif isinstance(obj, (list, tuple)):
    return extra_types.JsonValue(
        array_value=extra_types.JsonArray(
            entries=[METHOD_NAME(o, with_type=with_type) for o in obj]))
  elif isinstance(obj, dict):
    json_object = extra_types.JsonObject()
    for k, v in obj.items():
      json_object.properties.append(
          extra_types.JsonObject.Property(
              key=k, value=METHOD_NAME(v, with_type=with_type)))
    return extra_types.JsonValue(object_value=json_object)
  elif with_type:
    return METHOD_NAME(get_typed_value_descriptor(obj), with_type=False)
  elif isinstance(obj, str):
    return extra_types.JsonValue(string_value=obj)
  elif isinstance(obj, bytes):
    return extra_types.JsonValue(string_value=obj.decode('utf8'))
  elif isinstance(obj, bool):
    return extra_types.JsonValue(boolean_value=obj)
  elif isinstance(obj, int):
    if _MININT64 <= obj <= _MAXINT64:
      return extra_types.JsonValue(integer_value=obj)
    else:
      raise TypeError('Can not encode {} as a 64-bit integer'.format(obj))
  elif isinstance(obj, float):
    return extra_types.JsonValue(double_value=obj)
  elif isinstance(obj, ValueProvider):
    if obj.is_accessible():
      return METHOD_NAME(obj.get())
    return extra_types.JsonValue(is_null=True)
  else:
    raise TypeError('Cannot convert %s to a JSON value.' % repr(obj))