NAME
WWW::Hetzner::Role::JSONBool - Helper role for JSON boolean values in the Hetzner API
VERSION
version 0.102
SYNOPSIS
package WWW::Hetzner::Cloud::API::Widgets;
use Moo;
with 'WWW::Hetzner::Role::JSONBool';
sub create {
my ($self, %params) = @_;
my $body = { enabled => _json_bool($params{enabled}) };
return $self->client->post('/widgets', $body);
}
DESCRIPTION
The Hetzner API expects JSON booleans (true/false) for boolean fields. A Perl 0 or 1 is encoded as a JSON number and the API rejects such a request with invalid_input. This role provides the _json_bool helper that normalizes a Perl value into a JSON boolean.
The helper is a plain function call, not a method call:
$body->{enabled} = _json_bool($params{enabled});
_json_bool
my $bool = _json_bool($value);
Normalizes $value into a JSON boolean: \1 for a true value, \0 for a false one. A \0 or \1 reference is dereferenced first, so \0 becomes false and not the true value of a reference.
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-hetzner/issues.
IRC
Join #kubernetes on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.