aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2022-01-01 17:15:05 +0000
committerLouis Pilfold <louis@lpil.uk>2022-01-01 17:15:05 +0000
commite9421e168de9428c6b260e67f808f0d4db032cd5 (patch)
tree8ff47b9ff58c7336c651e740920c31a66fd7b41c /src
parentc3d35312ca49089e9603971270a44b83c3b0527d (diff)
downloadgleam_json-e9421e168de9428c6b260e67f808f0d4db032cd5.tar.gz
gleam_json-e9421e168de9428c6b260e67f808f0d4db032cd5.zip
float encoder
Diffstat (limited to 'src')
-rw-r--r--src/gleam/json.gleam12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gleam/json.gleam b/src/gleam/json.gleam
index c649ac3..8c3652c 100644
--- a/src/gleam/json.gleam
+++ b/src/gleam/json.gleam
@@ -98,6 +98,18 @@ pub external fn bool(input: Bool) -> Json =
pub external fn int(input: Int) -> Json =
"thoas_encode" "integer"
+/// Encode an float into JSON.
+///
+/// ## Examples
+///
+/// ```gleam
+/// > to_string(float(4.7))
+/// "4.7"
+/// ```
+///
+pub external fn float(input: Float) -> Json =
+ "thoas_encode" "float"
+
/// The JSON value null.
///
/// ## Examples