aboutsummaryrefslogtreecommitdiffstats
path: root/src/document/typed.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-02 11:07:46 +0100
committertv <tv@krebsco.de>2026-11-02 11:07:46 +0100
commita7b8b4d6543c4c780334df1c823d2e2f10d9e1bf (patch)
tree12cf1ad634ed128c40bfd9b6c9b9283dc81b3908 /src/document/typed.rs
parent694661d7477e4bd1e8d7ec96dcc37742d1b5ca3f (diff)
api: drop $float as JSON number is OK
Diffstat (limited to 'src/document/typed.rs')
-rw-r--r--src/document/typed.rs14
1 files changed, 3 insertions, 11 deletions
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": "<base64>"}`, `{"$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": "<base64>"}`, `{"$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<Jso
return Some(tagged("$timestamp", form.timestamps.json(*t)));
}
ScalarValue::Bytes(b) => 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(),