| 1589 | #endif |
| 1590 | |
| 1591 | bool CJsonObject::AddNull(const std::string& strKey) |
| 1592 | { |
| 1593 | cJSON* pFocusData = NULL; |
| 1594 | if (m_pJsonData != NULL) |
| 1595 | { |
| 1596 | pFocusData = m_pJsonData; |
| 1597 | } |
| 1598 | else if (m_pExternJsonDataRef != NULL) |
| 1599 | { |
| 1600 | pFocusData = m_pExternJsonDataRef; |
| 1601 | } |
| 1602 | else |
| 1603 | { |
| 1604 | m_pJsonData = cJSON_CreateObject(); |
| 1605 | m_pKeyTravers = m_pJsonData; |
| 1606 | pFocusData = m_pJsonData; |
| 1607 | } |
| 1608 | |
| 1609 | if (pFocusData == NULL) |
| 1610 | { |
| 1611 | m_strErrMsg = "json data is null!"; |
| 1612 | return(false); |
| 1613 | } |
| 1614 | if (pFocusData->type != cJSON_Object) |
| 1615 | { |
| 1616 | m_strErrMsg = "not a json object! json array?"; |
| 1617 | return(false); |
| 1618 | } |
| 1619 | if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) != NULL) |
| 1620 | { |
| 1621 | m_strErrMsg = "key exists!"; |
| 1622 | return(false); |
| 1623 | } |
| 1624 | cJSON* pJsonStruct = cJSON_CreateNull(); |
| 1625 | if (pJsonStruct == NULL) |
| 1626 | { |
| 1627 | return(false); |
| 1628 | } |
| 1629 | cJSON_AddItemToObject(pFocusData, strKey.c_str(), pJsonStruct); |
| 1630 | if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) == NULL) |
| 1631 | { |
| 1632 | return(false); |
| 1633 | } |
| 1634 | m_pKeyTravers = pFocusData; |
| 1635 | return(true); |
| 1636 | } |
| 1637 | |
| 1638 | bool CJsonObject::Delete(const std::string& strKey) |
| 1639 | { |
nothing calls this directly
no test coverage detected