www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12332] New: std.json API broken without notice

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12332

           Summary: std.json API broken without notice
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrei erdani.com


--- Comment #0 from Andrei Alexandrescu <andrei erdani.com> 2014-03-09 10:51:33
PDT ---
See http://forum.dlang.org/thread/lfgot7$8lg$1 digitalmars.com for more info.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 09 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12332


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |thecybershadow gmail.com


--- Comment #1 from Vladimir Panteleev <thecybershadow gmail.com> 2014-03-09
20:05:24 EET ---
https://github.com/D-Programming-Language/phobos/pull/1988

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 09 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12332


Adam D. Ruppe <destructionator gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator gmail.com


--- Comment #2 from Adam D. Ruppe <destructionator gmail.com> 2014-03-09
11:49:53 PDT ---
Setting the type is something I was able to just comment out of my code to make
it work on the new std.json.

My thought is setting type could be done with max compatibility by:

* if the set is binary compatible (casting it doesn't cause memory safety
issues e.g. integer -> uinteger or string->string are OK, but string->array is
out since that breaks the length and integer->string is out since that's a wild
pointer) with what is already there, set it without changing contents.

* otherwise, reset the union to 0/null/type.init so it isn't used for un- safe
reinterpret casting while breaking minimum code.


These should handle both cases of

v.type = JSON_TYPE.STRING;
v.str = "foo";

and

v.integer = 10;
v.type = JSON_TYPE.UINTEGER;


Without sacrificing any safety.


another copy/paste from my experience on irc

One thing i had to refactor though was setting object fields. before i would
set value.object["foo"] = bar;, whereas with the new one, i would make the
object separately, then set it to the final thing all in one go (since
otherwise value. object["foo"] tries to GET the object then call opIndex on it,
which throws since the json type is null - that was a runtime break!)


But if the type setting works, this should work too. The problem I had was now
setting type = object would fail to compile, thus causing v.obj to throw. If
type=object works again, this might just work.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 09 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12332



--- Comment #3 from github-bugzilla puremagic.com 2014-03-10 08:23:35 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/ee7de10ee9063c6b7cbf35d8c95f92fce0fe6aed
fix Issue 12332 - std.json API broken without notice

https://github.com/D-Programming-Language/phobos/commit/193a285659c08477eacbd2baaa0a2d4ad26fd2ff
Merge pull request #1988 from CyberShadow/fix12332

fix Issue 12332 - std.json API broken without notice

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 10 2014