NAME
Minima::View::JSON - Render JSON views
SYNOPSIS
use Minima::View::JSON;
my $view = Minima::View::JSON->new(app => $app);
my $body = $view->render({ data => ... });
DESCRIPTION
Minima::View::JSON provides a view for generating JSON responses. Internally, it utilizes JSON to convert data structures into valid JSON strings. While the installation of JSON::XS is not mandatory, it is highly recommended for better performance.
Note: Minima::View::JSON encodes data as UTF-8.
METHODS
new
method new (app)
Creates a new instance of the class. Expects a Minima::App object as the app
parameter.
prepare_response
method prepare_response ($response)
Sets the appropriate Content-Type header on the provided Plack::Response object.
render
method render ($data = {})
Converts the given data structure into a JSON string and returns the result.
SEE ALSO
Minima, Minima::Controller, Minima::View, perlclass.
AUTHOR
Cesar Tessarin, <cesar@tessarin.com.br>.
Written in November 2024.