[phobos] Plans for std.json

Andrei Alexandrescu andrei at erdani.com
Thu Oct 28 11:21:22 PDT 2010


I agree that we should add a mention. Other opinions?

Andrei

On 10/28/10 2:14 CDT, Brian Schott wrote:
> The DMD 2.050 beta zip contains no mention of std.json being scheduled
> for eventual replacement. Is it really a good idea to have another
> release with this code included and no warning that it will eventually
> go away?
>
> On 10/23/2010 09:30 PM, Andrei Alexandrescu wrote:
>> I strongly believe std.json must be replaced. Here is my list of
>> grievances and requirements:
>>
>> * JSONValue is utterly unsafe because it relies on an open tagged
>> union. Essentially memory safety is entirely dependent on the user.
>>
>> * Even if the union were made safe, handling things with an enum is
>> antiquated. The code should use types throughout, a la Algebraic, or -
>> better yet - use Algebraic itself:
>>
>> struct JSONFalse {};
>> struct JSONTrue {};
>> struct JSONNull {};
>>
>> alias Algebraic!(
>>      string,
>>      long,
>>      This[string],
>>      This[],
>>      JSONTrue,
>>      JSONFalse,
>>      JSONNull
>> ) JSONValue;
>>
>> * The function parseJSON takes a range but not by reference, which
>> means there is no way for the caller to know the new range position
>> after having parsed one json object.
>>
>> * toJSON returns a string, which is inefficient for large objects. It
>> should take an output range.
>>
>> Even if we later add serialization based on json transport, a simple,
>> independent API would be beneficial for many. I'm thinking in fact of
>> adding support for Json in std.format by means of %j. So then you can
>> read and write Json stuff with writef and readf.
>>
>>
>> Andrei
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list