I wrote a JSON library

Manu turkeyman at gmail.com
Thu May 9 01:25:42 PDT 2013


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...


On 9 May 2013 17:21, w0rp <devw0rp at gmail.com> wrote:

> 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)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130509/6c772673/attachment.html>


More information about the Digitalmars-d mailing list