Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active August 26, 2019 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupyuen/ef92789353dc883c4da72f950e577fb4 to your computer and use it in GitHub Desktop.
Save lupyuen/ef92789353dc883c4da72f950e577fb4 to your computer and use it in GitHub Desktop.
macro_rules! parse {
...
(@$enc:ident @object $obj:ident [$($key:tt)+] ($value:expr) , $($rest:tt)*) => {
d!(adding key: $($key)+ value: $value to object: $obj);
// Append the key and value to the "values" array e.g.
// {"key":"device", "value":"010203"},
$crate::coap_item_str!(@$enc $obj, $($key)+, $value);
// Continue parsing the rest of the JSON.
$crate::parse!(@$enc @object $obj () ($($rest)*) ($($rest)*));
};
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment