MCPcopy Create free account
hub / github.com/Bwar/CJsonObject / AddNullAsFirst

Method AddNullAsFirst

CJsonObject.cpp:3617–3657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3615}
3616
3617bool CJsonObject::AddNullAsFirst()
3618{
3619 cJSON* pFocusData = NULL;
3620 if (m_pJsonData != NULL)
3621 {
3622 pFocusData = m_pJsonData;
3623 }
3624 else if (m_pExternJsonDataRef != NULL)
3625 {
3626 pFocusData = m_pExternJsonDataRef;
3627 }
3628 else
3629 {
3630 m_pJsonData = cJSON_CreateArray();
3631 pFocusData = m_pJsonData;
3632 }
3633
3634 if (pFocusData == NULL)
3635 {
3636 m_strErrMsg = "json data is null!";
3637 return(false);
3638 }
3639 if (pFocusData->type != cJSON_Array)
3640 {
3641 m_strErrMsg = "not a json array! json object?";
3642 return(false);
3643 }
3644 cJSON* pJsonStruct = cJSON_CreateNull();
3645 if (pJsonStruct == NULL)
3646 {
3647 return(false);
3648 }
3649 int iArraySizeBeforeAdd = cJSON_GetArraySize(pFocusData);
3650 cJSON_AddItemToArrayHead(pFocusData, pJsonStruct);
3651 int iArraySizeAfterAdd = cJSON_GetArraySize(pFocusData);
3652 if (iArraySizeAfterAdd == iArraySizeBeforeAdd)
3653 {
3654 return(false);
3655 }
3656 return(true);
3657}
3658
3659bool CJsonObject::Delete(int iWhich)
3660{

Callers

nothing calls this directly

Calls 4

cJSON_CreateArrayFunction · 0.85
cJSON_CreateNullFunction · 0.85
cJSON_GetArraySizeFunction · 0.85
cJSON_AddItemToArrayHeadFunction · 0.85

Tested by

no test coverage detected