1.0.2 • Published 9 months ago
@allnulled/jsontyped v1.0.2
jsontyped
To support types in JSON.
Installation
npm i -s @allnulled/jsontypedImportation
In node.js:
require("@allnulled/jsontyped");In html:
<script src="node_modules/@allnulled/jsontyped/jsontyped.js"></script>Usage
JsonTyped.parse(`"This could be a normal JSON"`);
JsonTyped.parse(`@message "This is another level of JSON"`);
JsonTyped.parse(`@deeper.types "This is a valid way of chaining ref types"`);
JsonTyped.parse(`@deeper/types/somewhere/else.js "This is also a valid way of chaining ref types"`);
JsonTyped.parse(`@file:///you/can/specify/protocol/too "This is also a valid way of chaining ref types"`);
JsonTyped.parse(`@http:///you/can/specify/protocol/too "This is also a valid way of chaining ref types"`);Basically, any type supports this "prefix" in which you specify, with these symbols and normal variable-accepted js symbols A-Za-z_$ +0-9.
Then it always translate the types to:
{
$protocol: null,
$type: "message",
$value: "This is another level of JSON"
}Which is also quite readable. You can customize the output re-building the parser, by npm run build.
Changelog
22 of January of 2025.
- Accepts URLs with protocol, host, path, querystring and section automatically parsed.
- Accepts also JavaScript object paths separated by "
.".