<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Perinci::Result::Format - Format envelope result

VERSION
    version 0.36

SYNOPSIS
DESCRIPTION
    This module formats enveloped result to YAML, JSON, etc. It uses
    Data::Format::Pretty for the backend. It is used by other Perinci
    modules like Perinci::CmdLine and Perinci::Access::HTTP::Server.

    The default supported formats are:

    *   json

        Using Data::Format::Pretty::YAML.

    *   text-simple

        Using Data::Format::Pretty::SimpleText.

    *   text-pretty

        Using Data::Format::Pretty::Text.

    *   text

        Using Data::Format::Pretty::Console.

    *   yaml

        Using Data::Format::Pretty::YAML.

VARIABLES
%Perinci::Result::Format::Formats =&gt; HASH
    Contains a mapping between format names and Data::Format::Pretty::*
    module names + MIME type.

$Enable_Decoration =&gt; BOOL (default: 1)
    Decorations include color or other markup, which might make a data
    structure like JSON or YAML string become invalid JSON/YAML. This should
    be turned off if one wants to send the formatting over network.

$Enable_Cleansing =&gt; BOOL (default: 0)
    If enabled, cleansing will be done to data to help make sure that data
    does not contain item that cannot be handled by formatter. for example,
    JSON format cannot handle circular references or complex types other
    than hash/array.

FUNCTIONS
    None is currently exported/exportable.

format($res, $format) =&gt; STR
    Format enveloped result $res with format named $format.

    Result metadata ("$res-&gt;[3]") is also checked for key named
    "result_format_options". The value should be a hash like this "{
    FORMAT_NAME =&gt; OPTS, ... }". This way, function results can specify the
    details of formatting. An example enveloped result:

     [200, "OK", ["foo", "bar", "baz"], {
         result_format_options =&gt; {
             "text"        =&gt; {list_max_columns=&gt;1},
             "text-pretty" =&gt; {list_max_columns=&gt;1},
         }
     }]

    The above result specifies that if it is displayed using "text" or
    "text-pretty" format, it should be displayed in one columns instead of
    multicolumns.

FAQ
  How to list supported formats?
    Simply:

     my @supported_formats = keys %Perinci::Result::Format::Formats;

  How to add support for new formats?
    First make sure that Data::Format::Pretty::&lt;FORMAT&gt; module is available
    for your format. Look on CPAN. If it's not, i't also not hard to create
    one.

    Then, add your format to %Perinci::Result::Format::Formats hash:

     use Perinci::Result::Format;

     # this means format named 'xml' will be handled by Data::Format::Pretty::XML
     $Perinci::Result::Format::Formats{xml} = ['XML', 'text/xml'];

SEE ALSO
    Data::Format::Pretty

HOMEPAGE
    Please visit the project's homepage at
    &lt;https://metacpan.org/release/Perinci-Result-Format&gt;.

SOURCE
    Source repository is at
    &lt;https://github.com/sharyanto/perl-Perinci-Result-Format&gt;.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    &lt;https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Result-Format
    &gt;

    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.

AUTHOR
    Steven Haryanto &lt;stevenharyanto@gmail.com&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2014 by Steven Haryanto.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>