You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let data = json!(oura::model::MetadataRecord{
label: "hello".to_string(),
content: oura::model::MetadatumRendition::IntScalar(2_i128.pow(90)),
});let json_value: oura::model::MetadataRecord = serde_json::from_value(data).unwrap();// unwrap fails here, Error("i128 is not supported", line: 0, column: 0)let parsed = serde_json::to_string(&json_value).unwrap();let data = serde_json::from_str::<oura::model::MetadataRecord>(&parsed).unwrap();println!("{:?}", parsed);println!("{:?}", data);
this change works:
#[derive(Serialize,Deserialize,Debug,Clone,PartialEq,Eq)]pubstructMetadataRecord{publabel:String,// no #[serde(flatten)]pubcontent:MetadatumRendition,}
a couple of solutions:
remove the flatten. makes the nested struct messy
serialize/deserialize to BigInt instead, including anything that is higher than Number.MAX_SAFE_INTEGER from JS
create a custom se/deserializer to output as those >= Number.MAX_SAFE_INTEGER as string
Note that when such software is used, numbers that are integers and
are in the range [-(2^53)+1, (2^53)-1] are interoperable in the
sense that implementations will agree exactly on their numeric
values
The text was updated successfully, but these errors were encountered:
MetadatumRendition
enum got ai128
, but fails because of a serde bug when using#[serde(flatten)]
. enablingarbitrary_precision
flag doesn't helpsee serde-rs/serde#1183
serde-rs/json#625
simple repro:
this change works:
a couple of solutions:
Number.MAX_SAFE_INTEGER
from JSregarding the interop in JSON types from the RFC https://datatracker.ietf.org/doc/html/rfc7159#page-7:
The text was updated successfully, but these errors were encountered: