From e9421e168de9428c6b260e67f808f0d4db032cd5 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Sat, 1 Jan 2022 17:15:05 +0000 Subject: float encoder --- src/gleam/json.gleam | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') 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 -- cgit v1.2.3