try_json_stringify#

langchain_core.tracers.stdout.try_json_stringify(obj: Any, fallback: str) str[source]#

Try to stringify an object to JSON.

Parameters:
  • obj (Any) – Object to stringify.

  • fallback (str) – Fallback string to return if the object cannot be stringified.

Returns:

A JSON string if the object can be stringified, otherwise the fallback string.

Return type:

str