aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-json.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/functions-json.cxx')
-rw-r--r--libbuild2/functions-json.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/libbuild2/functions-json.cxx b/libbuild2/functions-json.cxx
index 7551fa1..d7265ba 100644
--- a/libbuild2/functions-json.cxx
+++ b/libbuild2/functions-json.cxx
@@ -70,7 +70,29 @@ namespace build2
// for details).
//
if (v.type == json_type::object && v.object.size () == 1)
- return move (v.object.front ().value);
+ {
+ // Reverse simple JSON values to the corresponding fundamental type
+ // values for consistency with subscript/iteration (see
+ // json_subscript_impl() for background).
+ //
+ json_value& jr (v.object.front ().value);
+
+ switch (jr.type)
+ {
+#if 0
+ case json_type::null: return value (names {});
+#else
+ case json_type::null: return value ();
+#endif
+ case json_type::boolean: return value (jr.boolean);
+ case json_type::signed_number: return value (jr.signed_number);
+ case json_type::unsigned_number:
+ case json_type::hexadecimal_number: return value (jr.unsigned_number);
+ case json_type::string: return value (move (jr.string));
+ case json_type::array:
+ case json_type::object: return value (move (jr));
+ }
+ }
fail << "json object member expected instead of " << v.type << endf;
};