Esempio n. 1
0
std::string GD_API VariableStructureToJSON(const gd::Variable & variable)
{
    if ( !variable.IsStructure() ) {
        if ( variable.IsNumber() )
            return ToString(variable.GetValue());
        else
            return StringToQuotedJSONString(variable.GetString().c_str());
    }

    std::string str = "{";
    bool firstChild = true;
    for(std::map<std::string, gd::Variable>::const_iterator i = variable.GetAllChildren().begin();
        i != variable.GetAllChildren().end();++i)
    {
        if ( !firstChild ) str += ",";
        str += StringToQuotedJSONString(i->first.c_str())+": "+VariableStructureToJSON(i->second);

        firstChild = false;
    }

    str += "}";
    return str;
}
Esempio n. 2
0
unsigned int GD_API GetVariableChildCount(gd::Variable & variable)
{
    if (variable.IsStructure() == false) return 0;

    return variable.GetAllChildren().size();
}