RFC: std.json sucessor

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 22 05:39:08 PDT 2014


Am 22.08.2014 14:17, schrieb matovitch:
> Very nice ! I had started (and dropped) a json module based on Algebraic
> too. So without opDispatch you plan to use a syntax like jPerson["age"]
> = 10 ? You didn't use stdx.d.lexer. Any reason why ? (I am asking even
> if I never used this module.(never coded much in D in fact))

Exactly, that's the syntax you'd use for JSONValue. But my favorite way 
to work with most JSON data is actually to directly read the JSON string 
into a D struct using a serialization framework and then access the 
struct in a strongly typed way. This has both, less syntactic and less 
runtime overhead, and also greatly reduces the chance for field 
name/type related bugs.

The module is written against current Phobos, which is why stdx.d.lexer 
wasn't really an option. I'm also unsure if std.lexer would be able to 
handle the parsing required for JSON numbers and strings. But it would 
certainly be nice already if at least the token structure could be 
reused. However, it should also be possible to find a painless migration 
path later, when std.lexer is actually part of Phobos.


More information about the Digitalmars-d mailing list