apache_beam.internal.gcp.json_value module¶
JSON conversion utility functions.
-
apache_beam.internal.gcp.json_value.
get_typed_value_descriptor
(obj)[source]¶ For internal use only; no backwards-compatibility guarantees.
Converts a basic type into a @type/value dictionary.
Parameters: obj – A bytes, unicode, bool, int, or float to be converted. Returns: A dictionary containing the keys @type
andvalue
with the value for the@type
of appropriate type.Raises: TypeError
– if the Python object has a type that is not supported.
-
apache_beam.internal.gcp.json_value.
to_json_value
(obj, with_type=False)[source]¶ For internal use only; no backwards-compatibility guarantees.
Converts Python objects into extra_types.JsonValue objects.
Parameters: - obj – Python object to be converted. Can be
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 aJsonValue
.
Returns: A
JsonValue
object usingJsonValue
,JsonArray
andJsonObject
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
, andNone
. 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.- obj – Python object to be converted. Can be
-
apache_beam.internal.gcp.json_value.
from_json_value
(v)[source]¶ For internal use only; no backwards-compatibility guarantees.
Converts
extra_types.JsonValue
objects into Python objects.Parameters: v – JsonValue
object to be converted.Returns: A Python object structured as values, lists, and dictionaries corresponding to JsonValue
,JsonArray
andJsonObject
types.Raises: TypeError
– if theJsonValue
object contains a type that is not supported.The types supported are
str
,bool
,list
,dict
, andNone
. The Dataflow API returns JsonValue(s) in many places and it is quite convenient to be able to convert these hierarchical objects to much simpler Python objects.