title: mochijson2 or mochijson
body: <p>I'm encoding some data using mochijson2.
  But I found that it behaves strange on strings as lists.</p>
  
  <p>Example: </p>
  
  <blockquote>
    <p>mochijson2:encode("foo").</p>
    
    <p>[91,"102",44,"111",44,"111",93]</p>
  </blockquote>
  
  <p>Where "102", "111", "111" are $f, $o, $o encoded as strings
  44 are commas and 91 and 93 are square brakets.</p>
  
  <p>Of course if I output this somewhere I'll get string "[102,111,111]" which is obviously not that what I what.</p>
  
  <p>If i try</p>
  
  <blockquote>
    <p>mochijson2:encode(&lt;&lt;"foo">>).</p>
    
    <p>[34,&lt;&lt;"foo">>,34]</p>
  </blockquote>
  
  <p>So I again i get a list of two doublequotes and binary part within which can be translated to binary with list_to_binary/1</p>
  
  <p>Here is the question - why is it so inconsistent. I understand that there is a problem distingushing erlang list that should be encoded as json array and erlang string which should be encoded as json string, but at least can it output binary when i pass it binary?</p>
  
  <p>And the second question:
  Looks like mochijson outputs everything nice (cause it uses special tuple to designate arrays {array, ...})</p>
  
  <blockquote>
    <p>mochijson:encode(&lt;&lt;"foo">>).<br>
    "\"foo\""</p>
  </blockquote>
  
  <p>What's the difference between mochijson2 and mochijson? Performance? Unicode handling? Anything else?</p>
  
  <p>Thanks</p>