| 2166 | } |
| 2167 | |
| 2168 | bool CJsonObject::ReplaceWithNull(const std::string& strKey) |
| 2169 | { |
| 2170 | cJSON* pFocusData = NULL; |
| 2171 | if (m_pJsonData == NULL) |
| 2172 | { |
| 2173 | pFocusData = m_pExternJsonDataRef; |
| 2174 | } |
| 2175 | else |
| 2176 | { |
| 2177 | pFocusData = m_pJsonData; |
| 2178 | } |
| 2179 | if (pFocusData == NULL) |
| 2180 | { |
| 2181 | m_strErrMsg = "json data is null!"; |
| 2182 | return(false); |
| 2183 | } |
| 2184 | if (pFocusData->type != cJSON_Object) |
| 2185 | { |
| 2186 | m_strErrMsg = "not a json object! json array?"; |
| 2187 | return(false); |
| 2188 | } |
| 2189 | cJSON* pJsonStruct = cJSON_CreateNull(); |
| 2190 | if (pJsonStruct == NULL) |
| 2191 | { |
| 2192 | return(false); |
| 2193 | } |
| 2194 | #if __cplusplus < 201101L |
| 2195 | std::map<std::string, CJsonObject*>::iterator iter = m_mapJsonObjectRef.find(strKey); |
| 2196 | #else |
| 2197 | auto iter = m_mapJsonObjectRef.find(strKey); |
| 2198 | #endif |
| 2199 | if (iter != m_mapJsonObjectRef.end()) |
| 2200 | { |
| 2201 | if (iter->second != NULL) |
| 2202 | { |
| 2203 | delete (iter->second); |
| 2204 | iter->second = NULL; |
| 2205 | } |
| 2206 | m_mapJsonObjectRef.erase(iter); |
| 2207 | } |
| 2208 | cJSON_ReplaceItemInObject(pFocusData, strKey.c_str(), pJsonStruct); |
| 2209 | if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) == NULL) |
| 2210 | { |
| 2211 | return(false); |
| 2212 | } |
| 2213 | return(true); |
| 2214 | } |
| 2215 | |
| 2216 | int CJsonObject::GetArraySize() |
| 2217 | { |
nothing calls this directly
no test coverage detected