title: What is the Rust equivalent of a JavaScript object when encoding with msgpack?
body: <p>I'm trying to port a JavaScript <a href="https://github.com/kawanet/msgpack-lite" rel="nofollow noreferrer">library</a> which uses msgpack for encoding JavaScript objects to Rust. I found a Rust library for msgpack encoding/decoding, but I don't get what is the equivalent input format in Rust. </p>
  
  <p>This JavaScript code for encoding the object <code>{"a": 5, "b": 6}</code> 
  gives the output <code>82 a1 61 03 a1 62 05</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>const msgpack = require("msgpack-lite");
  msgpack.encode(obj);
  </code></pre>
  
  <p>I tried representing the object as a Rust struct and encoding it using <a href="https://docs.rs/rmp-serde/0.13.7/rmp_serde/" rel="nofollow noreferrer">rmp-serde</a> library</p>
  
  <pre><code>use rmp_serde::{Deserializer, Serializer};
  use serde::{Deserialize, Serialize};
  
  #[derive(Debug, Serialize, Deserialize)]
  pub struct Test {
      a: u32,
      b: u32,
  }
  
  fn main() {
      let mut buf = Vec::new();
      let val = Test { a: 3, b: 5 };
      val.serialize(&amp;mut Serializer::new(&amp;mut buf)).unwrap();
      println!("{:?}", buf);
  }
  </code></pre>
  
  <p>I get the output <code>[146, 3, 5]</code>. How do I represent JSON input in Rust?</p>