Browse Source

Added function to list json object member value names

ninjastone 11 years ago
parent
commit
b92aa88a73
2 changed files with 17 additions and 0 deletions
  1. 15 0
      Source/Engine/Resource/JSONValue.cpp
  2. 2 0
      Source/Engine/Resource/JSONValue.h

+ 15 - 0
Source/Engine/Resource/JSONValue.cpp

@@ -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();

+ 2 - 0
Source/Engine/Resource/JSONValue.h

@@ -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.