title: How do I use mochijson to encode an array of objects?
body: <p>I have two objects that I'd like to bundle up and ship in an array, encoded as JSON with mochijson. They are:</p>
  
  <pre><code>&gt; Book0 = {struct, [{"title", "a book"}, {"id", "1"}]}.      
  &gt; Book1 = {struct, [{"title", "another book"}, {"id", "2"}]}.
  </code></pre>
  
  <p>However, </p>
  
  <pre><code>&gt; mochijson:encode({struct, [{"books", [Book0, Book1]}]}).
  ** exception exit: {json_encode,{bad_char,{struct,[{"title","a book"},
                                                     {"id","1"}]}}}
       in function  mochijson:json_encode_string_unicode_1/1 (src/mochijson.erl, line 203)
       in call from mochijson:json_encode_string_unicode/1 (src/mochijson.erl, line 190)
       in call from mochijson:'-json_encode_proplist/2-fun-0-'/3 (src/mochijson.erl, line 151)
       in call from lists:foldl/3 (lists.erl, line 1197)
       in call from mochijson:json_encode_proplist/2 (src/mochijson.erl, line 154)
  </code></pre>
  
  <p>How do I structure my data for mochijson? I'm aware of this <a href="https://stackoverflow.com/questions/1123589/how-to-use-mochijson-to-encode-data-structure-in-erlang">article</a> but it, sadly, does not cover arrays of objects.</p>