diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-25 21:52:57 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-25 21:52:57 +0000 |
commit | 8b1c37dcd82e24b1249b00395f90b6b4b847563c (patch) | |
tree | 826db85c644c597ab1cfd9e1abab13661d348945 /protocols/Gadu-Gadu/src/avatar.cpp | |
parent | 2ee188ce51aed4ac7f88c746f6ee68a91f29bbbf (diff) |
fix for the correct json node validation
git-svn-id: http://svn.miranda-ng.org/main/trunk@13835 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu/src/avatar.cpp')
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 37a106802a..a02171539a 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -104,17 +104,17 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts) } else if (strncmp(resp->pData, "{\"result\":", 10) == 0){
//if this url returns json data (11.2013 gg convention)
- JSONROOT respJSON(resp->pData);
- if (respJSON != NULL) {
- JSONNODE* respJSONavatars = json_get(json_get(json_get(json_get(respJSON, "result"), "users"), "user"), "avatars");
- if (respJSONavatars != NULL) {
- JSONNODE *respJSONavatar = json_at(respJSONavatars, 0);
- ptrT respJSON_blank(json_as_string(json_get(respJSONavatar, "_blank")));
- ptrT respJSONoriginBigAvatar(json_as_string(json_get(respJSONavatar, "originBigAvatar")));
- ptrT respJSONtimestamp(json_as_string(json_get(respJSONavatar, "timestamp")));
- if (respJSON_blank && mir_tstrcmp(respJSON_blank, TEXT("1")) && respJSONoriginBigAvatar && respJSONtimestamp){
- *avatarurl = mir_t2a(respJSONoriginBigAvatar);
- *avatarts = mir_t2a(respJSONtimestamp);
+ JSONNode root = JSONNode::parse(resp->pData);
+ if (root) {
+ const JSONNode &respJSONavatars = root["result"].at("users").at("user").at("avatars");
+ if (respJSONavatars) {
+ const JSONNode &respJSONavatar = *respJSONavatars.begin();
+ std::string respJSON_blank = respJSONavatar["_blank"].as_string();
+ std::string respJSONoriginBigAvatar = respJSONavatar["originBigAvatar"].as_string();
+ std::string respJSONtimestamp = respJSONavatar["timestamp"].as_string();
+ if (respJSON_blank == "1" && !respJSONoriginBigAvatar.empty() && !respJSONtimestamp.empty()) {
+ *avatarurl = mir_strdup(respJSONoriginBigAvatar.c_str());
+ *avatarts = mir_strdup(respJSONtimestamp.c_str());
}
}
}
|