On Friday, 22 August 2014 at 12:39:08 UTC, Sönke Ludwig wrote:
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.


Completely agree, I am waiting for a serializer too. I would love to see something like cap'n proto in D.

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.

Ok. I think I remember there was a stdx.d.lexer's Json parser provided as sample.

Reply via email to