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 basestring, bool, int, or float to be converted. Returns: A dictionary containing the keys @typeandvaluewith the value for the@typeof 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 (
string,int,float,bool) will be wrapped in@type:valuedictionaries. Otherwise the straight value is encoded into aJsonValue.
Returns: A
JsonValueobject usingJsonValue,JsonArrayandJsonObjecttypes 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.JsonValueobjects into Python objects.Parameters: v – JsonValueobject to be converted.Returns: A Python object structured as values, lists, and dictionaries corresponding to JsonValue,JsonArrayandJsonObjecttypes.Raises: TypeError– if theJsonValueobject 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.