CCDictionary * CCJSONConverter::dictionaryFrom(const char *str) { cJSON * json = cJSON_Parse(str); CCAssert(json && json->type==cJSON_Object, "CCJSONConverter:wrong json format"); CCDictionary * dictionary = CCDictionary::create(); convertJsonToDictionary(json, dictionary); if (json) { cJSON_Delete(json); } return dictionary; }
__Dictionary * CCJSONConverter::dictionaryFrom(const char *str) { cJSON * json = cJSON_Parse(str); if (!json || json->type!=cJSON_Object) { if (json) { cJSON_Delete(json); } return NULL; } CCAssert(json && json->type==cJSON_Object, "CCJSONConverter:wrong json format"); __Dictionary * Dictionary = new __Dictionary(); convertJsonToDictionary(json, Dictionary); cJSON_Delete(json); return Dictionary; }