From a7b8b4d6543c4c780334df1c823d2e2f10d9e1bf Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 2 Nov 2026 11:07:46 +0100 Subject: api: drop $float as JSON number is OK --- src/document/typed.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/document/typed.rs') diff --git a/src/document/typed.rs b/src/document/typed.rs index 7f6e0cc..def06df 100644 --- a/src/document/typed.rs +++ b/src/document/typed.rs @@ -224,9 +224,9 @@ pub(crate) struct JsonForm { // Typed JSON is plain JSON but for what plain JSON shows as another type: a single-key // object whose key is a tag names it. `{"$uint": 5}`, `{"$counter": 5}`, // `{"$timestamp": "2026-11-01T21:50:20.345Z"}` (in the timestamp format asked), -// `{"$bytes": ""}`, `{"$float": 2}` (a float without a fraction, which JSON -// numbers don't keep apart from integers in every language), `{"$text": "…"}` (an -// Automerge text). A map whose only key starts with `$` is `{"$map": {…}}`, so that +// `{"$bytes": ""}`, `{"$text": "…"}` (an Automerge text). A float is a number, +// as in plain JSON; a number without a fraction written over a float stays one +// (`store::Sticky::Floats`). A map whose only key starts with `$` is `{"$map": {…}}`, so that // nothing else reads as a tag. /// A map's single key that is a tag, or would be taken for one. @@ -270,9 +270,6 @@ pub(crate) fn scalar_to_json(scalar: &ScalarValue, form: JsonForm) -> Option return Some(tagged("$bytes", BASE64.encode(b).into())), - ScalarValue::F64(f) if f.fract() == 0.0 => { - return Some(tagged("$float", serde_json::Number::from_f64(*f)?.into())); - } _ => {} } } @@ -590,11 +587,6 @@ impl Val { })?)) } "$counter" => Val::Scalar(ScalarValue::counter(integer(value)?)), - "$float" => Val::Scalar(ScalarValue::F64( - value - .as_f64() - .ok_or_else(|| format!("$float: not a number: {value}"))?, - )), "$timestamp" => { let text = match value { JsonValue::String(text) => text.clone(), -- cgit v1.3.1