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

Function encode

python/ee/serializer.py:278–300  ·  view source on GitHub ↗

Serialize an object to a JSON-compatible structure for API calls. Args: obj: The object to serialize. is_compound: Whether the encoding should factor out shared subtrees. for_cloud_api: Whether the encoding should be done for the Cloud API or the legacy API. unbound_name: Pr

(
    obj: Any,
    is_compound: bool = True,
    for_cloud_api: bool = True,
    unbound_name: str | None = None,
)

Source from the content-addressed store, hash-verified

276
277
278def encode(
279 obj: Any,
280 is_compound: bool = True,
281 for_cloud_api: bool = True,
282 unbound_name: str | None = None,
283) -> Any:
284 """Serialize an object to a JSON-compatible structure for API calls.
285
286 Args:
287 obj: The object to serialize.
288 is_compound: Whether the encoding should factor out shared subtrees.
289 for_cloud_api: Whether the encoding should be done for the Cloud API or the
290 legacy API.
291 unbound_name: Provides a name for unbound variables in objects. Unbound
292 variables are otherwise disallowed. See the Count Functions usage in
293 customfunction.py.
294
295 Returns:
296 A JSON-compatible structure representing the input.
297 """
298 serializer = Serializer(
299 is_compound, for_cloud_api=for_cloud_api, unbound_name=unbound_name)
300 return serializer._encode(obj) # pylint: disable=protected-access
301
302
303@_utils.accept_opt_prefix('opt_pretty')

Callers

nothing calls this directly

Calls 2

_encodeMethod · 0.95
SerializerClass · 0.85

Tested by

no test coverage detected