<div dir="ltr">This entire thread is a really good example of why all new modules should live in exp. for a year after birth before moving to std...</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 9 May 2013 17:21, w0rp <span dir="ltr"><<a href="mailto:devw0rp@gmail.com" target="_blank">devw0rp@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thursday, 9 May 2013 at 01:42:41 UTC, deadalnix wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Awesome. Another nice thing you can do it to use alias this on a @property to allow for implicit conversion to int.<br>
<br>
Overall, the API is super nice ! If performance don't matter, I definitively recommend to use the lib.<br>
</blockquote>
<br></div>
I'll have to experiment with the alias this idea.<br>
<br>
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.<br>

<br>
auto arr = jsonArray();<br>
<br>
arr ~= 1; // [1]<br>
arr ~= "foo"; // [1, "foo"]<br>
arr ~= jsonArray() // Currently: [1, "foo", []]<br>
<br>
auto another = jsonArray();<br>
another ~= 3;<br>
<br>
arr.array ~= another.array; // Always: [1, "foo", [], 3]<br>
<br>
I swear that I wrote a concat(JSON, JSON) function for this, but it's not there. That would have accomplished this:<br>
<br>
arr.concat(another)<br>
</blockquote></div><br></div>