MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / AddEmptySubObject

Method AddEmptySubObject

eval/LANE_evaluation/lane2d/src/CJsonObject.cpp:123–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123bool CJsonObject::AddEmptySubObject(const std::string& strKey)
124{
125 cJSON* pFocusData = NULL;
126 if (m_pJsonData != NULL)
127 {
128 pFocusData = m_pJsonData;
129 }
130 else if (m_pExternJsonDataRef != NULL)
131 {
132 pFocusData = m_pExternJsonDataRef;
133 }
134 else
135 {
136 m_pJsonData = cJSON_CreateObject();
137 m_pKeyTravers = m_pJsonData;
138 pFocusData = m_pJsonData;
139 }
140
141 if (pFocusData == NULL)
142 {
143 m_strErrMsg = "json data is null!";
144 return(false);
145 }
146 if (pFocusData->type != cJSON_Object)
147 {
148 m_strErrMsg = "not a json object! json array?";
149 return(false);
150 }
151 if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) != NULL)
152 {
153 m_strErrMsg = "key exists!";
154 return(false);
155 }
156 cJSON* pJsonStruct = cJSON_CreateObject();
157 if (pJsonStruct == NULL)
158 {
159 m_strErrMsg = std::string("create sub empty object error!");
160 return(false);
161 }
162 cJSON_AddItemToObject(pFocusData, strKey.c_str(), pJsonStruct);
163 m_pKeyTravers = pFocusData;
164 return(true);
165}
166
167bool CJsonObject::AddEmptySubArray(const std::string& strKey)
168{

Callers

nothing calls this directly

Calls 3

cJSON_CreateObjectFunction · 0.85
cJSON_GetObjectItemFunction · 0.85
cJSON_AddItemToObjectFunction · 0.85

Tested by

no test coverage detected