I am receiving a stream of JSON string from a hardware. It works most of the time. But when the data getting more and more congested, I will encounter situation like below:
JSON string received is not yet complete
{ test: 'test1',
Multiple JSON string received
{ test: 'test1', valid: true }{ test: 'test2', valid: true }{ test:
In the example above.
- Case 1: I need to wait until the string is complete.
- Case 2: I wish to be able to extract the completed 2 Json strings and parse separately
Keep in mind that the above are for illustrative purposes only. In real life string might include {
or }
and, the string might use single or double quote, and the Json string is much longer, might contains multiple objects inside it.