Currently, the object class in json.h does not provide a way to iterate
over its keys. This commit adds an `iterate` method to the object class,
allowing users to iterate over the keys of a JSON object.

Signed-off-by: Yangyu Chen <[email protected]>

gcc/ChangeLog:

        * json.h (class object): Add iterate method to object class.
---
 gcc/json.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/json.h b/gcc/json.h
index fabe2fe0886a..0f01ee19a109 100644
--- a/gcc/json.h
+++ b/gcc/json.h
@@ -239,6 +239,11 @@ class object : public value
   void set_enum (const enum_property<EnumType> &property,
                 EnumType value);
 
+  bool iterate (unsigned i, const char **key) const
+  {
+    return m_keys.iterate (i, key);
+  }
+
   static int compare (const json::object &obj_a, const json::object &obj_b);
 
   size_t get_num_keys () const { return m_keys.length (); }
-- 
2.51.0

Reply via email to