www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Json

reply Mafi <mafi example.org> writes:
What is the current best practice for parsing JSON in D? What 
library (on code.dlang.org) should I use?

I do not want to (de-)serialize structs. Instead I want a simple 
DOM-API.

Thank you very much :)
Nov 17 2017
parent reply Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
On Friday, November 17, 2017 19:02:12 Mafi via Digitalmars-d-learn wrote:
 What is the current best practice for parsing JSON in D? What
 library (on code.dlang.org) should I use?

 I do not want to (de-)serialize structs. Instead I want a simple
 DOM-API.

 Thank you very much :)
I've typically used http://code.dlang.org/packages/std_data_json which comes from vibe.d and was a candidate for replacing std.json - though it didn't complete the review process, and I'm not sure that Sonke is interested in going through the effort of actually getting it into Phobos at this point (if I understand correctly, there were too many disagreements over what the final result should look like than there really being much wrong with std_data_json). But overall, I've found that it works reasonably well - certainly, it's better than using std.json. I don't know if it's quite what you're looking for though. Regardless, just searching on code.dlang.org gives plenty of hits for libraries to try out if std_data_json doesn't suit your fancy. - Jonathan M Davis
Nov 17 2017
parent reply bauss <jj_1337 live.dk> writes:
On Friday, 17 November 2017 at 19:12:04 UTC, Jonathan M Davis 
wrote:
 On Friday, November 17, 2017 19:02:12 Mafi via 
 Digitalmars-d-learn wrote:
 [...]
I've typically used http://code.dlang.org/packages/std_data_json which comes from vibe.d and was a candidate for replacing std.json - though it didn't complete the review process, and I'm not sure that Sonke is interested in going through the effort of actually getting it into Phobos at this point (if I understand correctly, there were too many disagreements over what the final result should look like than there really being much wrong with std_data_json). But overall, I've found that it works reasonably well - certainly, it's better than using std.json. I don't know if it's quite what you're looking for though. Regardless, just searching on code.dlang.org gives plenty of hits for libraries to try out if std_data_json doesn't suit your fancy. - Jonathan M Davis
Sadly it's not really updated and vibe.d's json module seems more stable, as it has had 60+ commits this year, while std_data_json hasn't been updated for over a year. It will probably work fine in general, but I assume it'll have a few gotchas here and there, as it seems like even vibe.d's module has that.
Nov 18 2017
parent reply kerdemdemir <kerdemdemir gmail.com> writes:
I am using vibe.d's json(http://vibed.org/api/vibe.data.json/) 
module without a problem and really happy with it. There are also 
some 
examples(https://github.com/vibe-d/vibe.d/tree/master/examples/json). If you
are using "dub" package manager it is also very easy to integrate vibe.d.
Nov 18 2017
parent reply Mafi <mafi example.org> writes:
On Saturday, 18 November 2017 at 14:25:58 UTC, kerdemdemir wrote:
 I am using vibe.d's json(http://vibed.org/api/vibe.data.json/) 
 module without a problem and really happy with it. There are 
 also some 
 examples(https://github.com/vibe-d/vibe.d/tree/master/examples/json). If you
are using "dub" package manager it is also very easy to integrate vibe.d.
Well, this would pull the whole vibe.d into the executable, wouldn't it? I'll stick with stdx.data.json for now, which I have tried and it does work in my case. But I'll minimize the actual json-interaction code so I can switch out the lib at any time. Thank you all! It's rather unfortunate that the (std lib) json situation is still not sorted out!
Nov 19 2017
parent bauss <jj_1337 live.dk> writes:
On Sunday, 19 November 2017 at 10:50:58 UTC, Mafi wrote:
 On Saturday, 18 November 2017 at 14:25:58 UTC, kerdemdemir 
 wrote:
 I am using vibe.d's json(http://vibed.org/api/vibe.data.json/) 
 module without a problem and really happy with it. There are 
 also some 
 examples(https://github.com/vibe-d/vibe.d/tree/master/examples/json). If you
are using "dub" package manager it is also very easy to integrate vibe.d.
Well, this would pull the whole vibe.d into the executable, wouldn't it? I'll stick with stdx.data.json for now, which I have tried and it does work in my case. But I'll minimize the actual json-interaction code so I can switch out the lib at any time. Thank you all! It's rather unfortunate that the (std lib) json situation is still not sorted out!
Well you could hand pick the two sub packages. https://github.com/vibe-d/vibe.d/tree/master/data https://github.com/vibe-d/vibe.d/tree/master/utils (data depends on this)
Nov 19 2017