www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Recommendations for best JSON lib?

reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
I only need to read arbitrary JSON data, no need for 
writing/(de)serialization.
Apr 20 2019
parent reply Guillaume Piolat <first.last gmail.com> writes:
On Saturday, 20 April 2019 at 18:49:07 UTC, Nick Sabalausky 
(Abscissa) wrote:
 I only need to read arbitrary JSON data, no need for 
 writing/(de)serialization.
std.json is simple as pie. import std.json: parseJSON; import std.file: read; JSONValue dubFile = parseJSON(cast(string)(read("dub.json"))); string name = dubFile["name"].str;
Apr 20 2019
parent reply evilrat <evilrat666 gmail.com> writes:
On Saturday, 20 April 2019 at 20:44:22 UTC, Guillaume Piolat 
wrote:
 On Saturday, 20 April 2019 at 18:49:07 UTC, Nick Sabalausky 
 (Abscissa) wrote:
 I only need to read arbitrary JSON data, no need for 
 writing/(de)serialization.
std.json is simple as pie.
However IIRC it fails with trailing commas, means that for reading user written JSON's it might be annoying. I also tried experimental std json, asdf and vibe.d. The only one that worked for me is vibe.d JSON subpackage, and adding simple commented lines stripping is simple with phobos, because there is absolutely no libraries that can handle JSON comments yet. (yes, I know it's not standard)
Apr 20 2019
next sibling parent Guillaume Piolat <first.last gmail.com> writes:
On Sunday, 21 April 2019 at 02:09:29 UTC, evilrat wrote:
 On Saturday, 20 April 2019 at 20:44:22 UTC, Guillaume Piolat 
 wrote:
 On Saturday, 20 April 2019 at 18:49:07 UTC, Nick Sabalausky 
 (Abscissa) wrote:
 I only need to read arbitrary JSON data, no need for 
 writing/(de)serialization.
std.json is simple as pie.
However IIRC it fails with trailing commas, means that for reading user written JSON's it might be annoying. I also tried experimental std json, asdf and vibe.d. The only one that worked for me is vibe.d JSON subpackage, and adding simple commented lines stripping is simple with phobos, because there is absolutely no libraries that can handle JSON comments yet. (yes, I know it's not standard)
I wrote a JSON parser just for this use case https://gitlab.com/AuburnSounds/rub/blob/master/source/permissivejson.d
Apr 21 2019
prev sibling next sibling parent Arjan <arjan ask.me.to> writes:
On Sunday, 21 April 2019 at 02:09:29 UTC, evilrat wrote:
 On Saturday, 20 April 2019 at 20:44:22 UTC, Guillaume Piolat 
 wrote:
 On Saturday, 20 April 2019 at 18:49:07 UTC, Nick Sabalausky
I also tried experimental std json, asdf and vibe.d. The only one that worked for me is vibe.d JSON subpackage, and
What was the problem with asdf? I've succesfully used it in the past.
Apr 21 2019
prev sibling parent Seb <seb wilzba.ch> writes:
On Sunday, 21 April 2019 at 02:09:29 UTC, evilrat wrote:
 On Saturday, 20 April 2019 at 20:44:22 UTC, Guillaume Piolat 
 wrote:
 On Saturday, 20 April 2019 at 18:49:07 UTC, Nick Sabalausky 
 (Abscissa) wrote:
 I only need to read arbitrary JSON data, no need for 
 writing/(de)serialization.
std.json is simple as pie.
However IIRC it fails with trailing commas, means that for reading user written JSON's it might be annoying. I also tried experimental std json, asdf and vibe.d. The only one that worked for me is vibe.d JSON subpackage, and adding simple commented lines stripping is simple with phobos, because there is absolutely no libraries that can handle JSON comments yet. (yes, I know it's not standard)
Experimental std.json is based on vibe.d's JSON package.
Apr 21 2019