The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Config::UCL - Perl bindings for libucl

SYNOPSIS

    use Config::UCL;
    use JSON::PP qw(to_json);

    my $hash = ucl_load("key1 : val1");
    say to_json $hash; # {"key1":"val1"}

    my $text = ucl_dump($hash);
    say $text; # key1 = "val1";

    # libucl-0.8.1/tests/schema/required.json
    my $data1  = { foo => 1 };
    my $data2  = { bar => 1 };
    my $schema = {
        properties => {
            foo => {},
            bar => {},
        },
        required => [qw(foo)],
    };
    say ucl_validate($schema, $data1); # 1
    say ucl_schema_error();            #
    say ucl_validate($schema, $data2); #
    say ucl_schema_error();            # object has missing property foo

DESCRIPTION

FUNCTIONS

$data = ucl_load($str, [$opt])

$opt hash reference is optional.

option ucl_parser_flags

Passed to ucl_parser_new(). https://github.com/vstakhov/libucl/blob/master/doc/api.md#ucl_parser_new

    UCL_PARSER_DEFAULT (default)
    UCL_PARSER_KEY_LOWERCASE
    UCL_PARSER_ZEROCOPY
    UCL_PARSER_NO_TIME
    UCL_PARSER_NO_IMPLICIT_ARRAYS
    UCL_PARSER_SAVE_COMMENTS
    UCL_PARSER_DISABLE_MACRO
    UCL_PARSER_NO_FILEVARS

option ucl_string_flags

Passed to ucl_string_flags ucl_object_fromstring_common(). https://github.com/vstakhov/libucl/blob/master/doc/api.md#ucl_object_fromstring_common

    UCL_STRING_RAW
    UCL_STRING_ESCAPE (default)
    UCL_STRING_TRIM
    UCL_STRING_PARSE_BOOLEAN
    UCL_STRING_PARSE_INT
    UCL_STRING_PARSE_DOUBLE
    UCL_STRING_PARSE_TIME
    UCL_STRING_PARSE_NUMBER
    UCL_STRING_PARSE
    UCL_STRING_PARSE_BYTES

option ucl_duplicate_strategy

Passed to ucl_duplicate_strategy ucl_parser_add_chunk_full().

    UCL_DUPLICATE_APPEND (default)
    UCL_DUPLICATE_MERGE
    UCL_DUPLICATE_REWRITE
    UCL_DUPLICATE_ERROR

option ucl_parse_type

Passed to ucl_duplicate_strategy ucl_parser_add_chunk_full().

    UCL_PARSE_UCL (default)
    UCL_PARSE_MSGPACK
    UCL_PARSE_CSEXP
    UCL_PARSE_AUTO

option utf8

The UTF8 flag of the key and value is turned on.

$data = ucl_load_file($filename, [$opt])

$opt is the same as ucl_load().

Internally ucl_parser_set_filevars() is called and ${CURDIR} is set.

$str = ucl_dump($data, [$opt])

$opt hash reference is optional.

option ucl_emitter

Passed to ucl_object_emit(). https://github.com/vstakhov/libucl/blob/master/doc/api.md#emitting-functions-1

    UCL_EMIT_JSON (default)
    UCL_EMIT_JSON_COMPACT
    UCL_EMIT_CONFIG
    UCL_EMIT_YAML
    UCL_EMIT_MSGPACK
    UCL_EMIT_MAX

option utf8

The UTF8 flag of the value is turned on.

$bool = ucl_validate($schema, $data)

Returns true or false.

If it is false, you can get the error string with ucl_schema_error().

$str = ucl_schema_error()

SEE ALSO

https://github.com/vstakhov/libucl

AUTHOR

Tomohiro Hosaka, <bokutin@bokut.in>

COPYRIGHT AND LICENSE

The Config::UCL module is Copyright (C) 2020 by Tomohiro Hosaka.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.