sindit-senml 0.3.0

Rust implementation of the SenML RFC8428 proposed standard
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mod tests {
    use sindit_senml::parse_json;
    #[test]
    fn test_float_roundtrip() {
        // If feature float_roundtrip
        #[cfg(feature = "float_roundtrip")]
        let number = "97.45365320034685";
        // else
        #[cfg(not(feature = "float_roundtrip"))]
        let number = "97.45365320034684";

        let json_str = format!(r#"[{{"n":"temperature","v":{},"t":1234567891.2}}]"#, number);
        let records = parse_json(&json_str, None).unwrap();
        let json_str_again = serde_json::to_string(&records).unwrap();
        assert_eq!(json_str, json_str_again);
    }
}