| 1552 | #endif |
| 1553 | |
| 1554 | bool CJsonObject::AddNull(const std::string& strKey) |
| 1555 | { |
| 1556 | cJSON* pFocusData = NULL; |
| 1557 | if (m_pJsonData != NULL) |
| 1558 | { |
| 1559 | pFocusData = m_pJsonData; |
| 1560 | } |
| 1561 | else if (m_pExternJsonDataRef != NULL) |
| 1562 | { |
| 1563 | pFocusData = m_pExternJsonDataRef; |
| 1564 | } |
| 1565 | else |
| 1566 | { |
| 1567 | m_pJsonData = cJSON_CreateObject(); |
| 1568 | m_pKeyTravers = m_pJsonData; |
| 1569 | pFocusData = m_pJsonData; |
| 1570 | } |
| 1571 | |
| 1572 | if (pFocusData == NULL) |
| 1573 | { |
| 1574 | m_strErrMsg = "json data is null!"; |
| 1575 | return(false); |
| 1576 | } |
| 1577 | if (pFocusData->type != cJSON_Object) |
| 1578 | { |
| 1579 | m_strErrMsg = "not a json object! json array?"; |
| 1580 | return(false); |
| 1581 | } |
| 1582 | if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) != NULL) |
| 1583 | { |
| 1584 | m_strErrMsg = "key exists!"; |
| 1585 | return(false); |
| 1586 | } |
| 1587 | cJSON* pJsonStruct = cJSON_CreateNull(); |
| 1588 | if (pJsonStruct == NULL) |
| 1589 | { |
| 1590 | return(false); |
| 1591 | } |
| 1592 | cJSON_AddItemToObject(pFocusData, strKey.c_str(), pJsonStruct); |
| 1593 | if (cJSON_GetObjectItem(pFocusData, strKey.c_str()) == NULL) |
| 1594 | { |
| 1595 | return(false); |
| 1596 | } |
| 1597 | m_pKeyTravers = pFocusData; |
| 1598 | return(true); |
| 1599 | } |
| 1600 | |
| 1601 | bool CJsonObject::Delete(const std::string& strKey) |
| 1602 | { |
no test coverage detected