title: Reading a JSON stream with boost::asio, get full string?
body: <p>I am reading a TCP stream using boost. The stream is in this format:</p>
  
  <pre><code>"{\"animationValues\":{\"mouth_rightMouth_stretch\":0.0000000000000000,\"mouth_leftMouth_narrow\":0.00000000000000000,\"mouth_up\":0.0000000000000000,\"mouth_leftMouth_stretch\":0.0000000000000000,\"mouth_rightMouth_narrow\":0.00000000000000000,\"mouth_down\":0.00000000000000000,\"mouth_upperLip_left_up\":0.0000000000000000,\"mouth_upperLip_right_up\":0.0000000000000000,\"mouth_lowerLip_left_down\":0.0000000000000000,\"mouth_lowerLip_right_down\":0.0000000000000000,\"mouth_leftMouth_frown\":0.0000000000000000,\"mouth_rightMouth_frown\":0.0000000000000000,\"mouth_leftMouth_smile\":0.00000000000000000,\"mouth_rightMouth_smile\":0.00000000000000000,\"eyes_lookRight\":0.0000000000000000,\"eyes_lookLeft\":0.00000000000000000,\"eyes_lookDown\":0.0000000000000000,\"eyes_lookUp\":0.00000000000000000,\"eyes_leftEye_blink\":0.00000000000000000,\"eyes_rightEye_blink\":0.00000000000000000,\"eyes_leftEye_wide\":0.0000000000000000,\"eyes_rightEye_wide\":0.0000000000000000,\"brows_leftBrow_up\":0.0000000000000000,\"brows_leftBrow_down\":0.00000000000000000,\"brows_rightBrow_up\":0.0000000000000000,\"brows_rightBrow_down\":0.00000000000000000,\"brows_midBrows_up\":0.0000000000000000,\"brows_midBrows_down\":0.00000000000000000,\"jaw_open\":0.0000000000000000,\"jaw_left\":0.0000000000000000,\"jaw_right\":0.00000000000000000,\"mouth_phoneme_oo\":0.0000000000000000,\"mouth_right\":0.0000000000000000,\"mouth_left\":0.00000000000000000,\"mouth_phoneme_mbp\":0.0000000000000000,\"mouth_phoneme_ch\":0.0000000000000000},\"headRot\":[0.0,0.0, 0.0]}";
  </code></pre>
  
  <p>I am trying to read this and parse each string as it comes in. So what I need to do is split the stream into sections that look like the above. I have tried:</p>
  
  <pre><code>  boost::system::error_code error;
      boost::asio::streambuf buffer;
      boost::asio::read_until(sock, buffer, "]}"", error);
      std::istream str(&amp;buffer);
  </code></pre>
  
  <p>but this only gives me half of the string that I need. I have tried:</p>
  
  <pre><code>boost::array&lt;char, 2046&gt; buf; 
  size_t len = sock.read_some(boost::asio::buffer(buf), error); 
  std::string data(buf.begin(), buf.end());
  </code></pre>
  
  <p>but this gives me even less. How can I read one section of the stream at a time? Thank you.</p>