On Thursday, 9 May 2013 at 01:42:41 UTC, deadalnix wrote:
Awesome. Another nice thing you can do it to use alias this on a @property to allow for implicit conversion to int.

Overall, the API is super nice ! If performance don't matter, I definitively recommend to use the lib.

I'll have to experiment with the alias this idea.

There are still a few things I need to work out. I'm missing an overload for opCmp (plus the host of math operators), and the append behaviour is perhaps strange. I had to choose between ~ meaning a JSON array is added to the LHS, [] ~ [1, 2] == [[1, 2]], or an array is concatenated, like the normal D arrays, [] ~ [1, 2] == [1, 2]. I went with the former for now, but I might have made the wrong choice. It all came about because of this.

auto arr = jsonArray();

arr ~= 1; // [1]
arr ~= "foo"; // [1, "foo"]
arr ~= jsonArray() // Currently: [1, "foo", []]

auto another = jsonArray();
another ~= 3;

arr.array ~= another.array; // Always: [1, "foo", [], 3]

I swear that I wrote a concat(JSON, JSON) function for this, but it's not there. That would have accomplished this:

arr.concat(another)

Reply via email to