| 1599 | } |
| 1600 | |
| 1601 | bool CJsonObject::Delete(const std::string& strKey) |
| 1602 | { |
| 1603 | cJSON* pFocusData = NULL; |
| 1604 | if (m_pJsonData == NULL) |
| 1605 | { |
| 1606 | pFocusData = m_pExternJsonDataRef; |
| 1607 | } |
| 1608 | else |
| 1609 | { |
| 1610 | pFocusData = m_pJsonData; |
| 1611 | } |
| 1612 | if (pFocusData == NULL) |
| 1613 | { |
| 1614 | m_strErrMsg = "json data is null!"; |
| 1615 | return(false); |
| 1616 | } |
| 1617 | if (pFocusData->type != cJSON_Object) |
| 1618 | { |
| 1619 | m_strErrMsg = "not a json object! json array?"; |
| 1620 | return(false); |
| 1621 | } |
| 1622 | cJSON_DeleteItemFromObject(pFocusData, strKey.c_str()); |
| 1623 | #if __cplusplus < 201101L |
| 1624 | std::map<std::string, CJsonObject*>::iterator iter = m_mapJsonObjectRef.find(strKey); |
| 1625 | #else |
| 1626 | auto iter = m_mapJsonObjectRef.find(strKey); |
| 1627 | #endif |
| 1628 | if (iter != m_mapJsonObjectRef.end()) |
| 1629 | { |
| 1630 | if (iter->second != NULL) |
| 1631 | { |
| 1632 | delete (iter->second); |
| 1633 | iter->second = NULL; |
| 1634 | } |
| 1635 | m_mapJsonObjectRef.erase(iter); |
| 1636 | } |
| 1637 | m_pKeyTravers = pFocusData; |
| 1638 | return(true); |
| 1639 | } |
| 1640 | |
| 1641 | bool CJsonObject::Replace(const std::string& strKey, const CJsonObject& oJsonObject) |
| 1642 | { |
no test coverage detected