MCPcopy
hub / github.com/google/earthengine-api / toJSON

Function toJSON

python/ee/serializer.py:305–319  ·  view source on GitHub ↗

Serialize an object to a JSON string appropriate for API calls. Args: obj: The object to serialize. pretty: True to pretty-print the object. for_cloud_api: Whether the encoding should be done for the Cloud API or the legacy API. Returns: A JSON string representing the inp

(obj, pretty: bool = False, for_cloud_api: bool = True)

Source from the content-addressed store, hash-verified

303@_utils.accept_opt_prefix('opt_pretty')
304# pylint: disable-next=g-bad-name
305def toJSON(obj, pretty: bool = False, for_cloud_api: bool = True) -> Any:
306 """Serialize an object to a JSON string appropriate for API calls.
307
308 Args:
309 obj: The object to serialize.
310 pretty: True to pretty-print the object.
311 for_cloud_api: Whether the encoding should be done for the Cloud API or the
312 legacy API.
313
314 Returns:
315 A JSON string representing the input.
316 """
317 serializer = Serializer(not pretty, for_cloud_api=for_cloud_api)
318 encoded = serializer._encode(obj) # pylint: disable=protected-access
319 return json.dumps(encoded, indent=2 if pretty else None)
320
321
322# pylint: disable-next=g-bad-name

Callers 1

toReadableJSONFunction · 0.85

Calls 2

_encodeMethod · 0.95
SerializerClass · 0.85

Tested by

no test coverage detected