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

Method AddEmptySubArray

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

Source from the content-addressed store, hash-verified

165}
166
167bool CJsonObject::AddEmptySubArray(const std::string& strKey)
168{
169 cJSON* pFocusData = NULL;
170 if (m_pJsonData != NULL)
171 {
172 pFocusData = m_pJsonData;
173 }
174 else if (m_pExternJsonDataRef != NULL)
175 {
176 pFocusData = m_pExternJsonDataRef;
177 }
178 else
179 {
180 m_pJsonData = cJSON_CreateObject();
181 m_pKeyTravers = m_pJsonData;
182 pFocusData = m_pJsonData;
183 }
184
185 if (pFocusData == NULL)
186 {
187 m_strErrMsg = "json data is null!";
188 return(false);
189 }
190 if (pFocusData->type != cJSON_Object)
191 {
192 m_strErrMsg = "not a json object! json array?";
193 return(false);
194 }
195 if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) != NULL)
196 {
197 m_strErrMsg = "key exists!";
198 return(false);
199 }
200 cJSON* pJsonStruct = cJSON_CreateArray();
201 if (pJsonStruct == NULL)
202 {
203 m_strErrMsg = std::string("create sub empty array error!");
204 return(false);
205 }
206 cJSON_AddItemToObject(pFocusData, strKey.c_str(), pJsonStruct);
207 m_pKeyTravers = pFocusData;
208 return(true);
209}
210
211bool CJsonObject::GetKey(std::string& strKey)
212{

Callers

nothing calls this directly

Calls 4

cJSON_CreateObjectFunction · 0.85
cJSON_GetObjectItemFunction · 0.85
cJSON_CreateArrayFunction · 0.85
cJSON_AddItemToObjectFunction · 0.85

Tested by

no test coverage detected