MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / AddEmptySubObject

Method AddEmptySubObject

common/map_sdk/transmission/src/CJsonObject.cpp:42–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42bool 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
70bool CJsonObject::AddEmptySubArray(const std::string& strKey) {
71 cJSON* pFocusData = NULL;

Callers

nothing calls this directly

Calls 2

cJSON_CreateObjectFunction · 0.85
cJSON_AddItemToObjectFunction · 0.85

Tested by

no test coverage detected