On Tuesday, 7 April 2015 at 16:37:15 UTC, Sönke Ludwig wrote:
Anyone up to this? The issues of the previous discussion [1] have all been addressed now more or less, so the package is ready for a more thorough review.

Code: https://github.com/s-ludwig/std_data_json
Docs: http://s-ludwig.github.io/std_data_json/

[1]: http://forum.dlang.org/thread/lt5s76$is$1...@digitalmars.com#post-lt5s76:24is:241:40digitalmars.com

Out of curiosity I tried to use this lib in lately discussed benchmark [1]

Original values on my machine (dmd 2.067, gdc 4.8.4, ldc2 0.15.1 llvm 3.5.1):
D - 10.22s, 1322.7Mb
D Gdc - 24.30s, 926.8Mb
D Ldc - 25.93s, 925.8Mb

With this lib it gets to [2]:
D - 7.48s, 1794.0Mb
Gdc and Ldc cannot build it with release (debug works) [3] and [4]

I also tried it with vibe.d's json [5]:
D - 44.77s, 2752.5Mb
D Gdc - 163.79s, 936.5Mb
D Ldc - 165.52s, 935.0Mb

So it seems that the new lib is a way to go.

As a newb to D I would like to know if there is a more elegant way to write: auto coordinates = jval.get!(JSONValue[string])["coordinates"].get!(JSONValue[]);

and

x += val.opt("x").coerce!double;

I tried to fiddle with used JSONValue, Algebraic and VariantN things, but without success. It's also weird (and undocumented in examples how to use the JSONValue other than in asserts) that this works:
JSONValue a = 12;
assert(a == 12.0);

and this is not:
long b = a;

I'd like if something like this can be possible:
auto coords = parseJson(text)["coordinates"];
foreach (val; coordinates) {
    x += val["x"].get!double;
    y += cast(double)val["y"];
    z += to!double(val["z"]);
  }

Also is there some way to use this lib for serialization and deserialization of normal objects? To use it like: auto coords = parseJson(text)["coordinates"].map!(a=>cast(SomeStruct)a);


[1] https://github.com/kostya/benchmarks/tree/master/json
[2] http://pastebin.com/22xX6V0J
[3] http://pastebin.com/WshDpnQD
[4] http://pastebin.com/zj13Z7yG
[5] http://pastebin.com/FLLXBCe1

Reply via email to