Provide a trait (and Attribute role) for JSON Marshal/Unmarshal where the JSON names aren't Perl identifiers
Perl6
Latest commit 62ab52a Jan 21, 2017 @jonathanstowe Rename META file
Permalink
Failed to load latest commit information.
lib/JSON No use version literal in :ver Mar 11, 2016
t Add module and tests Nov 9, 2015
.gitignore Add precomp Mar 11, 2016
.travis.yml Add all the things Nov 9, 2015
LICENCE rename LICENCE as en_GB May 30, 2016
META6.json Rename META file Jan 21, 2017
README.md Update README Jan 21, 2017

README.md

JSON::Name

Provide a trait (and Attribute role) for JSON Marshal/Unmarshal where the JSON names aren't Perl identifiers

Synopsis

use JSON::Name;

class MyClass {
	# The attribute meta object will have the role JSON::Name::NamedAttribute
   # applied and "666.evil.name" will be stored in it's json-name attribute
   has $.nice-name is json-name('666.evil.name');

}

Description

This is released as a dependency of JSON::Marshal and JSON::Unmarshal in order to save duplication, it is intended to store a separate JSON name for an attribute where the name of the JSON attribute might be changed, either for aesthetic reasons or the name is not a valid Perl identifier. It will of course also be needed in classes thar are going to use JSON::Marshal or JSON::Unmarshal for serialisation/de-serialisation.

Of course it could be used in other modules for a similar purpose.

Installation

Assuming you have a working Rakudo Perl 6 installation you should be able to install this with panda :

# From the source directory

panda install .

# Remote installation

panda install JSON::Name

This should work equally well with zef but I haven't tested it.

Support

Suggestions/patches are welcomed via github at

https://github.com/jonathanstowe/JSON-Name

Licence

This is free software.

Please see the LICENCE file in the distribution

© Jonathan Stowe 2015, 2016, 2017