//ERDDAP/com.cohort.util/ScriptString2/toJson
toJson
[JVM]
open fun toJson(f: Float): String
This makes a JSON version of a float.
Return
"null" if not finite. Return an integer if it ends with ".0". Else returns the number as a string.
Parameters
JVM
f |
[JVM]
open fun toJson(d: Double): String
This makes a JSON version of a number.
Return
"null" if not finite. Return an integer if it ends with ".0". Else returns the number as a string.
Parameters
JVM
d |
[JVM]
open fun toJson(s: String): String
This makes a JSON version of a string (\, \f, \n, \r, \t and " are escaped with a backslash character and double quotes are added before and after). null is returned as null. This variant encodes char #127 and above.
Return
the JSON-encoded string surrounded by "'s.
Parameters
JVM
s |
[JVM]
open fun toJson(s: String, firstUEncodedChar: Int): String
This makes a JSON version of a string (\, \f, \n, \r, \t and " are escaped with a backslash character and double quotes are added before and after). null is returned as null. This variant encodes char #127 and above as \uhhhh.
Return
the JSON-encoded string surrounded by "'s.
Parameters
JVM
s | The String to be encoded. |
firstUEncodedChar | The first char to be \uhhhh encoded, commonly 127, 256, or 65536. |
[JVM]
open fun toJson(s: String, firstUEncodedChar: Int, encodeNewline: Boolean): String
This is a variant of toJson that lets you encode newlines or not.
Return
the JSON-encoded string surrounded by "'s.
Parameters
JVM
s | The String to be encoded. |
firstUEncodedChar | The first char to be \uhhhh encoded, commonly 127, 256, or 65536. |