www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23393] New: JSONValue: Appending object to array fails

https://issues.dlang.org/show_bug.cgi?id=23393

          Issue ID: 23393
           Summary: JSONValue: Appending object to array fails
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider this code:

```
JSONValue test = parseJSON(`{"a": [{"b": 5}]}`);
test["a"] ~= test["a"][0];
```

Expected: `{"a": [{"b": 5}, {"b": 5}]}`
Got: std.json.JSONException std/json.d(355): JSONValue is not an array

Notably, this works:

```
test["a"] ~= JSONValue([test["a"][0]]);
```

--
Oct 07 2022