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

Method Get

CJsonObject.cpp:662–694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662bool CJsonObject::Get(const std::string& strKey, CJsonObject& oJsonObject) const
663{
664 cJSON* pJsonStruct = NULL;
665 if (m_pJsonData != NULL)
666 {
667 if (m_pJsonData->type == cJSON_Object)
668 {
669 pJsonStruct = cJSON_GetObjectItem(m_pJsonData, strKey.c_str());
670 }
671 }
672 else if (m_pExternJsonDataRef != NULL)
673 {
674 if(m_pExternJsonDataRef->type == cJSON_Object)
675 {
676 pJsonStruct = cJSON_GetObjectItem(m_pExternJsonDataRef, strKey.c_str());
677 }
678 }
679 if (pJsonStruct == NULL)
680 {
681 return(false);
682 }
683 char* pJsonString = cJSON_Print(pJsonStruct);
684 std::string strJsonData = pJsonString;
685 free(pJsonString);
686 if (oJsonObject.Parse(strJsonData))
687 {
688 return(true);
689 }
690 else
691 {
692 return(false);
693 }
694}
695
696bool CJsonObject::Get(const std::string& strKey, std::string& strValue) const
697{

Callers 1

mainFunction · 0.80

Calls 4

cJSON_GetObjectItemFunction · 0.85
cJSON_PrintFunction · 0.85
cJSON_GetArrayItemFunction · 0.85
ParseMethod · 0.80

Tested by

no test coverage detected