jeudi 30 juillet 2020

Parsing a complete JSON array from a text buffer

I'm receiving a JSON array over web sockets, and I have a buffer which is built up, currently I'm assuming that I'll receive the complete JSON array, with nested JSON objects and arrays. But I know from experience that often these strings can be broken up. So I need to check for a valid JSON array before I should try to process the text. Obviously due to the nested arrays, I can't just check for the presence of an opening and a closing square bracket.

I'm using libcereal to parse the JSON, but I can't see anything in the documents to suggest that it can do this. What would people suggest would be the simplest thing? A C++11 regex for JSON?

Aucun commentaire:

Enregistrer un commentaire