Exemplo n.º 1
0
DicItemType CJsonPacker::getItemTypeFromArray(const char *pszArrayKey, int nIndex)
{
    CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex);
    if (arrayValue)
        return (DicItemType)((*arrayValue)[nIndex].type());
    
    return (DicItemType)CSJson::nullValue;
}
Exemplo n.º 2
0
const char * CJsonPacker::getStringValueFromArray(const char *pszArrayKey, int nIndex)
{
    CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex);
    if (arrayValue)
    {
        if ((*arrayValue)[nIndex].isString())
            return (*arrayValue)[nIndex].asCString();
    }
    
    return NULL;
}
Exemplo n.º 3
0
double CJsonPacker::getFloatValueFromArray(const char *pszArrayKey, int nIndex, double fDefaultValue)
{
    double fRet = fDefaultValue;
    CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex);
    if (arrayValue)
    {
        if ((*arrayValue)[nIndex].isNumeric())
            fRet = (*arrayValue)[nIndex].asDouble();
    }
    
    return fRet;
}
Exemplo n.º 4
0
int CJsonPacker::getIntValueFromArray(const char *pszArrayKey, int nIndex, int nDefaultValue)
{
    int nRet = nDefaultValue;
    CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex);
    if (arrayValue)
    {
        if ((*arrayValue)[nIndex].isNumeric())
            nRet = (*arrayValue)[nIndex].asInt();
    }
    
    return nRet;
}
 bool CSJsonDictionary::getBoolValueFromArray(const char *pszArrayKey, int nIndex, int nDefaultValue)
 {
     bool nRet = nDefaultValue;
     Json::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex);
     if (arrayValue)
     {
         if ((*arrayValue)[nIndex].isNumeric())
             nRet = (*arrayValue)[nIndex].asBool();
     }
     
     return nRet;
 }
Exemplo n.º 6
0
CJsonPacker * CJsonPacker::getSubItemFromArray(const char *pszArrayKey, int nIndex)
{
    CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex);
    if (arrayValue)
    {
        if ((*arrayValue)[nIndex].isArray() || (*arrayValue)[nIndex].isObject())
        {
            CJsonPacker * pNewDictionary = new CJsonPacker();
            pNewDictionary->initWithValue((*arrayValue)[nIndex]);
            return pNewDictionary;
        }
    }
    
    return NULL;
}