toJson

Converts a Map with String keys and nullable Any values into a Map with String keys and JsonElement values.

Each value in the resulting map is derived from the corresponding value in the input map, transformed into a JsonElement. If the transformation fails for any reason, the value is replaced with a JsonPrimitive containing the original value's toString representation.

Return

A new map where the values are converted to JsonElement instances.