title: How can I convert a struct or JSON into a raw string?
body: <p>I have tests and  I need to send JSON data to my server. I have the following test:</p>
  
  <pre><code>extern crate hyper;
  extern crate rustc_serialize;
  
  use std::io::Read;
  use hyper::*;
  
  #[derive(RustcDecodable, RustcEncodable)]
  struct LegacyJsonRequest {
      jsonrpc: String,
      method: String,
      params: String,
      id: i32,
      auth: String,
  }
  
  #[test]
  fn apiinfo_jsonrpc_tests() {
      let client = Client::new();
  
      let url = "http://localhost:6767/api_jsonrpc.php";
  
      let mut http_reader = header::Headers::new();
      http_reader.set_raw("Content-Type", vec![b"application/json".to_vec()]);
  
      //TODO: How to use a struct and 'export' it to a raw string literal???
      let request_data = LegacyJsonRequest {
          jsonrpc: "2.0".to_string(),
          method: "apiinfo.version".to_string(),
          params: "[]".to_string(),
          auth: "[]".to_string(),
          id: 1,
      };
  
      let encoded_request = rustc_serialize::json::encode(&amp;request_data).unwrap();
  
      let mut response = client.post(url)
          .body(encoded_request)
          .send()
          .unwrap();
  
  }
  </code></pre>
  
  <p>With this code, the following error is returned:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `hyper::client::Body&lt;'_&gt;: std::convert::From&lt;std::string::String&gt;` is not satisfied
  </code></pre>
  
  <p>If I <strong>drop the struct and JSON encoded code and create a simple raw string literal</strong> and reference it on the body method, it works. Example:</p>
  
  <pre><code>extern crate hyper;
  extern crate rustc_serialize;
  
  use std::io::Read;
  use hyper::*;
  
  #[derive(RustcDecodable, RustcEncodable)]
  struct LegacyJsonRequest {
      jsonrpc: String,
      method: String,
      params: String,
      id: i32,
      auth: String,
  }
  
  #[test]
  fn apiinfo_jsonrpc_tests() {
      let client = Client::new();
  
      let url = "http://localhost:6767/api_jsonrpc.php";
  
      let mut http_reader = header::Headers::new();
      http_reader.set_raw("Content-Type", vec![b"application/json".to_vec()]);
  
      let request_data =
          r#"{"jsonrpc":"2.0", "method": "apiinfo.version", "params": {}, "auth": {}, "id": "1"}"#;
  
      let mut response = client.post(url)
          .body(request_data)
          .send()
          .unwrap();
  
  }
  </code></pre>
  
  <p>So: How can I convert my struct or JSON into a <strong>raw string</strong>? </p>
  
  <p>I Know that the error E0277 is about the implementation of a trait for the "Hyper::client::Body&lt;'_>", but look, this is not the question; the question is: how to convert a struct or JSON into a raw string, nothing more. Thanks.</p>