about summary refs log tree commit diff
path: root/src/libutil/json.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/json.hh')
-rw-r--r--src/libutil/json.hh14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libutil/json.hh b/src/libutil/json.hh
index 595e9bbe3491..02a39917fb5c 100644
--- a/src/libutil/json.hh
+++ b/src/libutil/json.hh
@@ -21,11 +21,11 @@ protected:
         std::ostream & str;
         bool indent;
         size_t depth = 0;
-        std::vector<JSONWriter *> stack;
+        size_t stack = 0;
         JSONState(std::ostream & str, bool indent) : str(str), indent(indent) { }
         ~JSONState()
         {
-            assert(stack.empty());
+            assert(stack == 0);
         }
     };
 
@@ -41,7 +41,7 @@ protected:
 
     void assertActive()
     {
-        assert(!state->stack.empty() && state->stack.back() == this);
+        assert(state->stack != 0);
     }
 
     void comma();
@@ -117,6 +117,14 @@ public:
         open();
     }
 
+    JSONObject(const JSONObject & obj) = delete;
+
+    JSONObject(JSONObject && obj)
+        : JSONWriter(obj.state)
+    {
+        obj.state = 0;
+    }
+
     ~JSONObject();
 
     template<typename T>