phpser2sereal - Convert between serialization formats
This document describes version 0.165 of phpser2sereal (from Perl distribution App-SerializeUtils), released on 2022-03-20.
Usage:
% serializeutils-convert [OPTIONS] < INPUT-FILE
For example, when called as json2yaml:
json2yaml
% script-that-outputs-json | json2yaml
This script can be called as various names to convert between serialization formats.
"perl" refers to Perl format, generated using Data::Dump or Data::Dumper and parsed using Perl's eval() or Data::Undump.
eval()
"perlcolor" refers to colored Perl format, generated using Data::Dump::Color.
"json" is of course the popular JavaScript Object Notation described in https://www.json.org.
"phpser" refers to PHP serialization format. This document describes the format in more details: http://www.phpinternalsbook.com/classes_objects/serialization.html. To serialize/deserialize this format, the script uses PHP::Serialization.
"sereal" refers to the Sereal format, described in https://github.com/Sereal/Sereal/blob/master/sereal_spec.pod.
"storable" refers to the Storable format.
"yaml" is the Yet Another Markup Language format specified in https://www.yaml.org.
The script are installed as the following names for convenience:
perl2perlcolor perl2json perl2phpser perl2sereal perl2storable perl2yaml json2perl json2perlcolor json2phpser json2sereal json2storable json2yaml phpser2perl phpser2perlcolor phpser2json phpser2sereal phpser2storable phpser2yaml sereal2perl sereal2perlcolor sereal2json sereal2phpser sereal2storable sereal2yaml storable2perl storable2perlcolor storable2json storable2phpser storable2sereal storable2yaml yaml2perl yaml2perlcolor yaml2json yaml2phpser yaml2sereal yaml2storable
--(no-)color
Only applies to output formats perl, perlcolor, json, yaml.
perl
perlcolor
json
yaml
Whether to use colors. The default is from the COLOR environment variable, or 1 when script is called interactively.
--(no-)compact
Only applies to output formats json, perl.
Whether to produce compact output. The default is false when outputing interactively. For format perl, will use Data::Dmp when producing compact output.
--(no-)safe
Only applies to input format perl.
Whether to parse safely. The default is false, which means parsing using Perl's eval. When set to true, will parse using Data::Undump but parsing might fail for more complex input, e.g. recursive data structures.
eval
--dumper=s
Only applies to output format perl.
Set which dumper to use. Can be set to Data::Dump or Data::Dump::Color or Data::Dumper. The default is Data::Dump.
Data::Dump
Data::Dump::Color
Data::Dumper
This script has shell tab completion capability with support for several shells.
To activate bash completion for this script, put:
complete -C phpser2sereal phpser2sereal
in your bash startup (e.g. ~/.bashrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.
~/.bashrc
It is recommended, however, that you install modules using cpanm-shcompgen which can activate shell completion for scripts immediately.
To activate tcsh completion for this script, put:
complete phpser2sereal 'p/*/`phpser2sereal`/'
in your tcsh startup (e.g. ~/.tcshrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.
~/.tcshrc
It is also recommended to install shcompgen (see above).
shcompgen
For fish and zsh, install shcompgen as described above.
Set the default for --color option.
--color
Please visit the project's homepage at https://metacpan.org/release/App-SerializeUtils.
Source repository is at https://github.com/perlancar/perl-App-SerializeUtils.
App::SerializeUtils
perlancar <perlancar@cpan.org>
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.
This software is copyright (c) 2022, 2021, 2020, 2018, 2017, 2015, 2014, 2013, 2011 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-SerializeUtils
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.
To install App::SerializeUtils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::SerializeUtils
CPAN shell
perl -MCPAN -e shell install App::SerializeUtils
For more information on module installation, please visit the detailed CPAN module installation guide.