title: Encoding Javascript Object to Json string
body: <p>I want to encode a Javascript object into a JSON string and I am having considerable difficulties.</p>
  
  <p>The Object looks something like this</p>
  
  <pre><code>new_tweets[k]['tweet_id'] = 98745521;
  new_tweets[k]['user_id'] = 54875;       
  new_tweets[k]['data']['in_reply_to_screen_name'] = "other_user";
  new_tweets[k]['data']['text'] = "tweet text";
  </code></pre>
  
  <p>I want to get this into a JSON string to put it into an ajax request.</p>
  
  <pre><code>{'k':{'tweet_id':98745521,'user_id':54875, 'data':{...}}}
  </code></pre>
  
  <p>you get the picture. No matter what I do, it just doesn't work. All the JSON encoders like json2 and such produce</p>
  
  <pre><code>[]
  </code></pre>
  
  <p>Well, that does not help me. Basically I would like to have something like the php <code>encodejson</code> function.  </p>