title: Sending/Parsing multiple JSON objects
body: <p>I have a Sinatra server that is returning multiple JSON objects from the database in a streaming manner.  The objects would look like:</p>
  
  <pre><code>{"a": 1, "b": 2, "c": 3}
  {"a": 4, "b": 5, "c": 6}
  ...
  </code></pre>
  
  <p>but this is invalid JSON.  I can add a hack into Sinatra's event processing (manually injecting the missing array delimiters) to make the response look like:</p>
  
  <pre><code>[
  {"a": 1, "b": 2, "c": 3}
  , {"a": 4, "b": 5, "c": 6}
  ]
  </code></pre>
  
  <p>which is valid JSON now, but this technique is inelegant.  Is there some way to do this client-side?  Basically, what I want is to have a JavaScript function read a string and consume a valid JSON object, and then return to me the JSON object and the remainder of the string, iteratively being called until the entire string is consumed.</p>