const CJSONValue &CJSONValue::GetElement (int iIndex) const // GetElement // // Returns the element by index { switch (m_iType) { case typeArray: { ArrayType *pArray = (ArrayType *)m_pValue; if (iIndex < 0 || iIndex >= pArray->GetCount()) return g_NullValue; return pArray->GetAt(iIndex); } case typeObject: { ObjectType *pObj = (ObjectType *)m_pValue; if (iIndex < 0 || iIndex >= pObj->GetCount()) return g_NullValue; return pObj->GetValue(iIndex); } default: return g_NullValue; } }
int CJSONValue::GetCount (void) const // GetCount // // Returns the number of elements { switch (m_iType) { case typeNull: return 0; case typeArray: { ArrayType *pArray = (ArrayType *)m_pValue; return pArray->GetCount(); } case typeObject: { ObjectType *pObj = (ObjectType *)m_pValue; return pObj->GetCount(); } default: return 1; } }