| 2203 | } |
| 2204 | |
| 2205 | bool CJsonObject::ReplaceWithNull(const std::string& strKey) |
| 2206 | { |
| 2207 | cJSON* pFocusData = NULL; |
| 2208 | if (m_pJsonData == NULL) |
| 2209 | { |
| 2210 | pFocusData = m_pExternJsonDataRef; |
| 2211 | } |
| 2212 | else |
| 2213 | { |
| 2214 | pFocusData = m_pJsonData; |
| 2215 | } |
| 2216 | if (pFocusData == NULL) |
| 2217 | { |
| 2218 | m_strErrMsg = "json data is null!"; |
| 2219 | return(false); |
| 2220 | } |
| 2221 | if (pFocusData->type != cJSON_Object) |
| 2222 | { |
| 2223 | m_strErrMsg = "not a json object! json array?"; |
| 2224 | return(false); |
| 2225 | } |
| 2226 | cJSON* pJsonStruct = cJSON_CreateNull(); |
| 2227 | if (pJsonStruct == NULL) |
| 2228 | { |
| 2229 | return(false); |
| 2230 | } |
| 2231 | #if __cplusplus < 201101L |
| 2232 | std::map<std::string, CJsonObject*>::iterator iter = m_mapJsonObjectRef.find(strKey); |
| 2233 | #else |
| 2234 | auto iter = m_mapJsonObjectRef.find(strKey); |
| 2235 | #endif |
| 2236 | if (iter != m_mapJsonObjectRef.end()) |
| 2237 | { |
| 2238 | if (iter->second != NULL) |
| 2239 | { |
| 2240 | delete (iter->second); |
| 2241 | iter->second = NULL; |
| 2242 | } |
| 2243 | m_mapJsonObjectRef.erase(iter); |
| 2244 | } |
| 2245 | cJSON_ReplaceItemInObject(pFocusData, strKey.c_str(), pJsonStruct); |
| 2246 | if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) == NULL) |
| 2247 | { |
| 2248 | return(false); |
| 2249 | } |
| 2250 | return(true); |
| 2251 | } |
| 2252 | |
| 2253 | int CJsonObject::GetArraySize() const |
| 2254 | { |
nothing calls this directly
no test coverage detected