diff options
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 02775b85f3..616b77c833 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -1165,11 +1165,20 @@ int FacebookProto::ParseUnreadThreads(std::string *data, std::vector< std::strin int FacebookProto::ParseThreadMessages(std::string *data, std::vector< facebook_message >* messages, bool unreadOnly) { - // cuts out the rest - size_t len = data->find("\r\n"); + // cuts out the rest (summary result) + size_t len = data->find("\r\n{\n \"successful_results"); if (len != data->npos) data->erase(len); + // make data to be valid json (queries are standalone JSONs --> merge them into one) + std::string::size_type n = 0; + std::string replaceFrom = "}\r\n{"; + std::string replaceTo = ", "; + while ((n = data->find(replaceFrom, n)) != std::string::npos) { + data->replace(n, replaceFrom.size(), replaceTo); + n += replaceTo.size(); + } + JSONNode root = JSONNode::parse(data->c_str()); if (!root) return EXIT_FAILURE; |