https://github.com/jonathanstowe/json-name
Provide a trait (and Attribute role) for JSON Marshal/Unmarshal where the JSON names aren't Raku identifiers
https://github.com/jonathanstowe/json-name
json meta raku
Last synced: 6 days ago
JSON representation
Provide a trait (and Attribute role) for JSON Marshal/Unmarshal where the JSON names aren't Raku identifiers
- Host: GitHub
- URL: https://github.com/jonathanstowe/json-name
- Owner: jonathanstowe
- License: artistic-2.0
- Created: 2015-11-09T14:18:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-08-07T08:44:22.000Z (almost 3 years ago)
- Last Synced: 2025-06-07T08:05:44.250Z (about 1 month ago)
- Topics: json, meta, raku
- Language: Raku
- Homepage:
- Size: 16.6 KB
- Stars: 3
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
# JSON::Name
Provide a trait (and Attribute role) for JSON Marshal/Unmarshal where the JSON names aren't Raku identifiers.

## Synopsis
```raku
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](https://github.com/jonathanstowe/JSON-Marshal) and
[JSON::Unmarshal](https://github.com/tadzik/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 Raku 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 installation you should be able to install this with *zef* :
# From the source directory
zef install .# Remote installation
zef install JSON::Name
## Support
Suggestions/patches are welcomed via github at https://github.com/jonathanstowe/JSON-Name
## Licence
This is free software.
Please see the [LICENCE](LICENCE) file in the distribution
© Jonathan Stowe 2015 - 2021