diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-02-20 09:37:50 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-02-20 16:01:40 +0200 |
commit | 6ff1cf35f78a24d52603d84eac9349b3d4670c6c (patch) | |
tree | 3c549345e303b25617b70e96800f8d1fbb7a9595 /libbuild2/json.hxx | |
parent | c2d2a1ac0ac41a068c4bf09f8236a61d576e74f5 (diff) |
Make json value type prepend non-overriding for consistency with map
Diffstat (limited to 'libbuild2/json.hxx')
-rw-r--r-- | libbuild2/json.hxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libbuild2/json.hxx b/libbuild2/json.hxx index 538c87d..96596e3 100644 --- a/libbuild2/json.hxx +++ b/libbuild2/json.hxx @@ -170,16 +170,22 @@ namespace build2 // values are incompatible. Note that for numbers this can also lead to // the change of the value type. // - // Append/prepend to an object overrides existing members. Append/prepend - // an array to an array splices in the array elements rather than adding - // an element of the array type. + // Append/prepend an array to an array splices in the array elements + // rather than adding an element of the array type. + // + // By default, append to an object overrides existing members while + // prepend does not. In a sense, whatever appears last is kept, which is + // consistent with what we expect to happen when specifying the same name + // repeatedly (provided it's not considered invalid) in a text + // representation (e.g., {"a":1,"a":2}). Position-wise, both append and + // prepend retain the positions of existing members with append inserting + // new ones at the end while prepend -- at the beginning. // void - append (json_value&&); + append (json_value&&, bool override = true); void - prepend (json_value&&); - + prepend (json_value&&, bool override = false); // Array element access. // |