www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22612] New: std.json doesn't parse duplicate keys

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

          Issue ID: 22612
           Summary: std.json doesn't parse duplicate keys
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: rumbu rumbu.ro

auto j = parseJSON(`{ "key": 1, "key" : 2 }`);
writeln(j); //outputs only {"key":2}

Of course, j["key"] contains 2, value 1 gets lost in translation.

According to ECMA-404:

"The JSON syntax does not impose any restrictions on the strings used as names,
does not require that name strings be unique, and does not assign any
significance to the ordering of name/value pairs"

--
Dec 19 2021