YAML::PP::Schema::JSON(3)

NAME
YAML::PP::Schema::JSON - YAML 1.2 JSON Schema

SYNOPSIS
    my $yp = YAML::PP->new( schema => ['JSON'] );
    my $yp = YAML::PP->new( schema => [qw/ JSON empty=str /] );
    my $yp = YAML::PP->new( schema => [qw/ JSON empty=null /] );

DESCRIPTION
With this schema, the resolution of plain values will work like in JSON. Everything that matches a special value will be loaded as such, other plain scalars will be loaded as strings.

Note that this is different from the official YAML 1.2 JSON Schema, where all strings have to be quoted.

Here you can see all Schemas and examples implemented by YAML::PP: <https://perlpunk.github.io/YAML-PP-p5/schemas.html>

Official Schema: <https://yaml.org/spec/1.2/spec.html#id2803231>

CONFIGURATION
The official YAML 1.2 JSON Schema wants all strings to be quoted. YAML::PP currently does not require that (it might do this optionally in the future).

That means, there are no empty nodes allowed in the official schema. Example:

    ---
    key:

The default behaviour of YAML::PP::Schema::JSON is to return an empty string, so it would be equivalent to:

    ---
    key: ''

You can configure it to resolve this as "undef":

    my $yp = YAML::PP->new( schema => [qw/ JSON empty=null /] );

This way it is equivalent to:

    ---
    key: null

The default is:

    my $yp = YAML::PP->new( schema => [qw/ JSON empty=str /] );

METHODS

register
    Called by YAML::PP::Schema

represent_bool, represent_float, represent_int, represent_literal, represent_undef
    Functions to represent the several node types.

        represent_bool($representer, $node);