painlessjson 0.7.0

Converting custom types to and from JSON the painless way.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Painless JSON Build Status

Library to painlessly convert your custom types (structs and classes) to and from JSON. This library provides the function toJSON and fromJSON to automatically convert any type to and from JSON. It is possible to override the implementation by defining your own _toJSON and _fromJSON member functions for a type. The default conversion works by converting all member variables of a type to and from JSON.

Installation

Installation is mostly managed through http://code.dlang.org, so you can add it to your dependencies in your dub.json file.

You can also generate the library by hand with:

git clone http://github.com/BlackEdder/painlessjson.git
cd painlessjson 
dub build -b release

Examples

struct Point
{
    double x = 0;
    double y = 0;
}

Point point;
auto json = point.toJSON; # => q{{"x":-1,"y":2}})
auto newPoint = fromJSON!Point(parseJSON(q{{"x":-1,"y":2}}));

More detailed can be found by generating the documentation

dub -b docs

Performance

On the backend this library uses std.json and performance is mainly determined by the std.json implementation. At the moment of writing (2014) std.json is known to be slow compared to other languages. Hopefully, this will be improved over time.

Tested compilers

dmd-2.066.1 DMD-2.065.0 DMD-2.064.2 LDC-0.14.0 LDC-0.15.1 GDC-4.9.0

Authors:
  • Edwin van Leeuwen
  • Pierre Krafft
Dependencies:
none
Versions:
1.4.0 2019-Jul-12
1.3.9 2018-Jul-07
1.3.8 2016-Nov-17
1.3.7 2016-Apr-14
1.3.6 2016-Jan-21
Show all 19 versions
Download Stats:
  • 4 downloads today

  • 19 downloads this week

  • 70 downloads this month

  • 80307 downloads total

Score:
1.5
Short URL:
painlessjson.dub.pm