| 40 | } |
| 41 | |
| 42 | bool CJsonObject::AddEmptySubObject(const std::string& strKey) { |
| 43 | cJSON* pFocusData = NULL; |
| 44 | if (m_pJsonData != NULL) { |
| 45 | pFocusData = m_pJsonData; |
| 46 | } else if (m_pExternJsonDataRef != NULL) { |
| 47 | pFocusData = m_pExternJsonDataRef; |
| 48 | } else { |
| 49 | m_pJsonData = cJSON_CreateObject(); |
| 50 | pFocusData = m_pJsonData; |
| 51 | } |
| 52 | |
| 53 | if (pFocusData == NULL) { |
| 54 | m_strErrMsg = "json data is null!"; |
| 55 | return (false); |
| 56 | } |
| 57 | if (pFocusData->type != cJSON_Object) { |
| 58 | m_strErrMsg = "not a json object! json array?"; |
| 59 | return (false); |
| 60 | } |
| 61 | cJSON* pJsonStruct = cJSON_CreateObject(); |
| 62 | if (pJsonStruct == NULL) { |
| 63 | m_strErrMsg = std::string("create sub empty object error!"); |
| 64 | return (false); |
| 65 | } |
| 66 | cJSON_AddItemToObject(pFocusData, strKey.c_str(), pJsonStruct); |
| 67 | return (true); |
| 68 | } |
| 69 | |
| 70 | bool CJsonObject::AddEmptySubArray(const std::string& strKey) { |
| 71 | cJSON* pFocusData = NULL; |
nothing calls this directly
no test coverage detected