std.json

Tim Shea tim.m.shea at gmail.com
Sun Jun 24 11:25:28 PDT 2012


On Thursday, 17 May 2012 at 18:55:57 UTC, Jarl André wrote:
> On Thursday, 17 May 2012 at 18:36:22 UTC, Jarl André wrote:
>> On Thursday, 17 May 2012 at 14:08:27 UTC, Vincent wrote:
>>> On Sunday, 25 March 2012 at 17:50:45 UTC, Andrea Fontana 
>>> wrote:
>>>> Hope it's clear...
>>>
>>> Nope, it's something like chess and have nothing common with 
>>> simplicity of the real JSON usage! This is example from C#:
>>>
>>> var p = JsonConvert.DeserializeObject<Person>("{some real 
>>> JSON, not crapy EOS}");
>>> var str = JsonConvert.SerializeObject(p);
>>>
>>> That's it! And this is how it SHOULD be implemented. Cannot 
>>> catch why this stupid realization came to standard library... 
>>> :((
>>
>> I'm pretty new to D, but I am an expert Java developer, self 
>> claimed. I am fluent in many other languages as well. In all 
>> languages there is a basis documentation.
>>
>> Read the documentation for parseJSON and you'll see that it 
>> should be possible to send in a straight JSON string. I think 
>> the complex example is a bit stupid. It scares developers away 
>> from the lang.
>>
>> Feel free to correct me of course.
>
> The final proof of exisiting simplicity :)
>
> JSONValue[string] value = parseJSON("{ \"test\": \"1\"
> }").object;
> writeln(value["test"].str);
>
> This outputs "1"

Vincent, I'm not sure what you are trying to claim by saying 
"some real JSON, not crappy EOS", all modern languages support 
special string delimiters to avoid escaping characters. This 
isn't a deficit it's a feature which improves readability. On the 
other hand, Phobos does (by design) tend towards minimalism, this 
is a legitimate library strategy, as it allows me to serialize 
and deserialize objects in whatever way suits me. Unfortunately 
it has the side effect that you don't get to have a built in 
function for every common task. It's a tradeoff.

Anyway, I just wanted to ask if we could get Ali or Jarl's (or 
both) samples added to the documentation. I read the docs, and 
having only worked with JSON in Javascript and PHP, wasn't quite 
clear how to use std.json. As it turns out, it's exactly what one 
would expect :D


More information about the Digitalmars-d-learn mailing list