From dfacdcde828fb19d084b4407b085e778bfca5373 Mon Sep 17 00:00:00 2001 From: Andreas Neuhaus Date: Tue, 10 Dec 2024 14:03:39 +0100 Subject: [PATCH] Allow JSON object values to be built from referenced key strings --- firmware/src/json/value.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/firmware/src/json/value.rs b/firmware/src/json/value.rs index b585c54..484720e 100644 --- a/firmware/src/json/value.rs +++ b/firmware/src/json/value.rs @@ -158,6 +158,12 @@ impl From> for Value { } } +impl From<[(&str, Value); N]> for Value { + fn from(value: [(&str, Value); N]) -> Self { + Self::Object(value.map(|(k, v)| (k.into(), v)).into()) + } +} + impl From<[(String, Value); N]> for Value { fn from(value: [(String, Value); N]) -> Self { Self::Object(value.into())