Jasonify - Just Another Serialized Object Notation library.
use Jasonify; my $jasonify = Jasonify->new( ... ); # See OPTIONS below $jasonify = $jasonify->set( ... ); # See OPTIONS below print $jasonify->encode( ... ); # ... # Or Jasonify->set( ... ); # See OPTIONS below print Jasonify->encode( ... ); # ...
Jasonify is very similar to JSON, except that it's easier to use, has better defaults and options.
Jasonify
How undef is encoded.
undef
How the boolean values are encoded.
Use double-quoted strings in all cases.
All strings are to be considered long, and encoded accordingly.
Special characters, and how they are encoded.
How to encode the values for infinity, negative infinity, and not-a-number.
Encode lvalues as simple strings.
lvalue
Encode vstrings as a series of 4-character hex digits separated by '\u'.
'\u'
A reference to an ARRAY is encoded in this manner.
ARRAY
A reference to a HASH is encoded in this manner.
HASH
Pairs are encoded in this manner.
The function used to sort entries in a hash.
How to filter items in a HASH.
How to interpret filtered items in a HASH.
The method to search for to see if an object has a specific representation for itself.
Objects are decomposed using this. If you wanted to decompose objects with the class name in addition to the internal representation of the data, then you may want to use '{$class_str : $data}'.
'{$class_str : $data}'
If objects have overloaded these, use them to decompose the object.
To enable tag output, set this to '($class_str)$data'.
'($class_str)$data'
The method to search for to see if an object should be represented in the tag format.
How IO objects will be decomposed.
How CODE references will be decomposed.
CODE
References will be ignored, and the actual value will be encoded.
When referring to a location in the reference, decompose with this.
How a FORMAT will be encoded.
FORMAT
new( ... )
Create a Jasonify object with the following options.
See "OPTIONS" for a description of the options and their default values.
Determine if values exists for one or more settings.
Can be called as a class method or an object method.
get( name, name, ... )
Get one or more existing values for one or more settings. If passed no names, returns all parameters and values.
set( name => value, name => value, ... )
Change the "OPTIONS" settings. When called as a class method, changes default options. When called as an object method, changes the settings and returns a new object.
NOTE: When called as a object method, this returns a new instance with the values set, so you will need to capture the return if you'd like to persist the change:
$jasonify = $jasonify->set( ... );
booleanify( value )
Returns the string that represents the true or false interpretation of value. If value is a scalar reference, calls itself with value dereferenced. Will return the value for undefify if value is not defined.
true
false
value
undefify
keyify( value )
Returns value as a key. NOTE: Numbers are always quoted when used as keys.
objectify( value )
Returns value as an object. Goes through a series of checks to format the object appropriately:
If a handler has been defined for the object with "add_handler( $class => \&code_ref )", then use that. If "tag" has been enabled, and the object has a method that corresponds to "tag_method", then that is used. If the object has a method that corresponds to "json_method", then that is used. If the object has overloaded any of "overloads => [ '""', '0+' ]", then use that to represent the $data portion of the object. If the object has an _attrkeyvals method, then that will be used to gather the elements of the object. If the object has none of those things, then the object is inspected and handled appropriately.
add_handler( $class => \&code_ref )
$data
_attrkeyvals
regexpify( value, delimiters )
Simply calls out to "stringify".
vstringify( value )
A representation of the VString. If "vformat" is specified, as a series of four digit hex values separated by '\\u'. If "vformat" is false, as a regular via "stringify".
'\\u'
scalarify( value )
This is the method called by "encode( value, ... )"
TODO: Returns value as a scalar. If value is not a reference, performs some magic to correctly print vstrings and numbers, otherwise assumes it's a string. If value is a reference, hands off to the correct function to create the string.
Handles reference loops.
decode( value, ... )
Decode one or more string representations of JSON.
JSON
NOTE: This method is not implemented yet, it is a placehold for future implementations.
encode( value, ... )
Encode one or more values to JSON formatted strings.
Can be called as a class or object method.
boolean( value )
If passed a value, returns the boolean for that value. If passed no value, retunrs the name of the class representing booleans.
Also aliased as bool( value ).
bool( value )
See "Jasonify::Boolean".
literal( value )
If passed a value, returns a representation of that value that, when encoded, will be exactly that value. If passed no value, returns the name of the class representing literals.
See "Jasonify::Literal".
number( value, ... )
If passed in a single value, returns a representation of that value that, when encoded, will be exactly that value. If passed in two or more values, returns a representation of that value when passed through to sprintf(). If passed no value, returns the name of the class representing numbers.
sprintf()
See "Jasonify::Number".
string( value )
If passed a value, returns a representation of that value that, when encoded, will be exactly that value as a string.
Please report any bugs or feature requests on the bugtracker website https://github.com/rkleemann/Jasonify/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Implement decode().
decode()
JSON, Datify
This document describes version v0.20.064 of this module.
Bob Kleemann <bobk@cpan.org>
This software is Copyright (c) 2020 by Bob Kleemann.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Jasonify, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jasonify
CPAN shell
perl -MCPAN -e shell install Jasonify
For more information on module installation, please visit the detailed CPAN module installation guide.