Any (working) JSON library for D2?

Johannes Pfau spam at example.com
Sun Jun 19 12:05:08 PDT 2011


Adam D. Ruppe wrote:
>Johannes Pfau wrote:
>> I guess you do not have similar helper functions to parse JSON?
>
>My other message has some. It isn't quite as nice to use though -
>getting structs and such takes a little bit of work.
>
>For example, I use it to get stuff from Facebook, and it
>looks kinda like this:
>
>===
>	auto request =
>	parseSignedRequest(signed_request).get!(Variant[string]);
>
>	if("page" in request) {
>		auto page = request["page"].get!(Variant[string]);
>		pageId = page["id"].coerce!string;
>		likes = page["liked"].get!bool;
>	}
>===
>
>It's not as beautiful as it could be, but it works reasonably
>well anyway, which is why I'm happy enough with it as it is.
>
>
>> Also how do you workaround bug #2962?
>
>I don't know anymore! For a while, I used a private fork of
>std.json with the floating point functionality removed and
>a utf related bug worked around, but now that fork is completely
>commented out and I just use the stock std.json.
>
>Problem is I don't remember if it's because the bugs got fixed
>upstream, or if they just didn't bother me anymore...
>
>Regardless though, it works in a test on my box at least.
>Paste that code into a fresh file.
>
>
>void main() {
>	auto v = jsonToVariant("4.2");
>	writeln(v.get!real);
>}
>
>compiles and runs correctly.

That's interesting, that code works indeed. Even more interesting:

dmd src/etc/curl.d src/vevo/cli/main.d src/vevo/api.d -ofvevo 
/usr/include/d/dmd/phobos/std/conv.d(1301): Error: function
std.conv.parse!(real,string).parse compiler error, parameter 'p',
bugzilla 2962? dmd: glue.c:744: virtual void
FuncDeclaration::toObjFile(int): Assertion `0' failed.

But this works:
dmd src/vevo/api.d src/etc/curl.d src/vevo/cli/main.d -ofvevo

The only difference is the argument order for dmd!
Thinking of it I think I saw a similar bug when compiling dustmite. It
consists of only two files, but it compiles only one way.

-- 
Johannes Pfau



More information about the Digitalmars-d-learn mailing list