title: How to convert Vec to JsonValue in Rust
body: <p>I am querying my database and getting an <code>Vec&lt;Bookable&gt;</code> struct, using diesel library.</p>
  
  <pre><code>#[derive(QueryableByName)]
  pub struct Bookable {
    #[sql_type = "BigInt"]
    pub id: i64,
    #[sql_type = "Text"]
    pub title: String
  }
  </code></pre>
  
  <p>When I query the elements, I can access the result, but it's not possible to convert the <code>Vec&lt;Bookable&gt;</code> to <code>json!</code> macro:</p>
  
  <pre><code>pub fn get_terms(conn: &amp;MysqlConnection) -&gt; Vec&lt;Bookable&gt; {
    diesel::sql_query(r#"SELECT title, LAST_INSERT_ID() 'id' from bookable_term;"#)
      .load::&lt;Bookable&gt;(conn).expect("Query failed")
  }
  </code></pre>
  
  <p>And later I call it this way:</p>
  
  <pre><code>  let conn = connect();
    let terms = bookable::get_terms(&amp;conn);
    json!({ "data": {
      "items": terms }
    })
  </code></pre>
  
  <p>The question is how to put the terms into this object and send the whole array to the API? I can stringify a json like this:</p>
  
  <pre><code>"items:" &amp;vec!["to", "be", "or", "not", "to", "be"]
  </code></pre>
  
  <p>But when it comes to an existing Vec I get compiler error. I am using <code>Rocket</code> so it provides a <code>rocket_contrib::json::JsonValue</code> which holds <code>json!</code> macro</p>