valueToString

open fun valueToString(value: Any): String

Make a JSON text of an Object value. If the object has an value.toJSONString() method, then that method will be used to produce the JSON text. The method is required to produce a strictly conforming text. If the object does not contain a toJSONString method (which is the most common case), then a text will be produced by other means. If the value is an array or Collection, then a JSONArray will be made from it and its toJSONString method will be called. If the value is a MAP, then a JSONObject will be made from it and its toJSONString method will be called. Otherwise, the value's toString method will be called, and the result will be quoted.

Warning: This method assumes that the data structure is acyclical.

Return

a printable, displayable, transmittable representation of the object, beginning with { (left brace) and ending with } (right brace).

Parameters

value

The value to be serialized.

Throws

If the value is or contains an invalid number.