Added function to list json object member value names

This commit is contained in:
ninjastone 2014-08-10 02:57:17 +09:00
parent 6347724b66
commit b92aa88a73
2 changed files with 17 additions and 0 deletions

View File

@ -292,6 +292,21 @@ Vector<String> JSONValue::GetChildNames() const
return ret;
}
Vector<String> JSONValue::GetValueNames() const
{
Vector<String> ret;
if (!IsObject())
return ret;
for (Value::ConstMemberIterator i = value_->MemberBegin(); i != value_->MemberEnd(); ++i)
{
if (i->value.GetType() != kArrayType && i->value.GetType() != kObjectType)
ret.Push(i->name.GetString());
}
return ret;
}
int JSONValue::GetInt(const String& name) const
{
return GetMember(name).GetInt();

View File

@ -127,6 +127,8 @@ public:
bool IsObject() const;
/// Return child names (only object and array child name).
Vector<String> GetChildNames() const;
/// Return member value names.
Vector<String> GetValueNames() const;
/// Return int.
int GetInt(const String& name) const;
/// Return bool.