Merge remote-tracking branch 'origin/master' into rj/misc

* origin/master:
  Upgrade to serde-json-core v0.2.0
This commit is contained in:
Robert Jördens 2021-02-15 08:55:40 +01:00
commit efbf750b20
3 changed files with 5 additions and 5 deletions

4
Cargo.lock generated
View File

@ -915,9 +915,9 @@ dependencies = [
[[package]] [[package]]
name = "serde-json-core" name = "serde-json-core"
version = "0.1.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf406405ada9ef326ca78677324ac66994ff348fc48a16030be08caeed29825" checksum = "89fd6016a00149b485f66da701f76d909210d319040c97b6eff300f6e2ba2153"
dependencies = [ dependencies = [
"heapless", "heapless",
"serde", "serde",

View File

@ -36,7 +36,7 @@ panic-semihosting = { version = "0.5", optional = true }
panic-halt = "0.2" panic-halt = "0.2"
serde = { version = "1.0", features = ["derive"], default-features = false } serde = { version = "1.0", features = ["derive"], default-features = false }
heapless = { version = "0.5", features = ["serde"] } heapless = { version = "0.5", features = ["serde"] }
serde-json-core = "0.1" serde-json-core = "0.2"
cortex-m-rtic = "0.5.5" cortex-m-rtic = "0.5.5"
embedded-hal = "0.2.4" embedded-hal = "0.2.4"
nb = "1.0.0" nb = "1.0.0"

View File

@ -40,7 +40,7 @@ macro_rules! route_request {
$( $(
$write_attribute => { $write_attribute => {
let new_value = match serde_json_core::from_str::<$TYPE>(&$request.value) { let new_value = match serde_json_core::from_str::<$TYPE>(&$request.value) {
Ok(data) => data, Ok((data, _)) => data,
Err(_) => return server::Response::error($request.attribute, Err(_) => return server::Response::error($request.attribute,
"Failed to decode value"), "Failed to decode value"),
}; };
@ -253,7 +253,7 @@ impl Server {
&self.data[..self.data.len() - 1], &self.data[..self.data.len() - 1],
); );
match r { match r {
Ok(mut res) => { Ok((mut res, _)) => {
// Note that serde_json_core doesn't escape quotations within a string. // Note that serde_json_core doesn't escape quotations within a string.
// To account for this, we manually translate all single quotes to // To account for this, we manually translate all single quotes to
// double quotes. This occurs because we doubly-serialize this field in // double quotes. This occurs because we doubly-serialize this field in