YAML::P...a::JSON(3)

πŸ’– NAME πŸ’–

okay so welcome to the YAML::P...a::JSON(3) page from the User Contributed Perl Documentation, bestie β€” this one's all about YAML::PP::Schema::JSON, aka the YAML 1.2 JSON Schema, and she's iconic πŸ’…βœ¨

✨ SYNOPSIS ✨

Three lil ways to summon the vibe:

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 works like JSON: everything that matches a special value gets loaded as that special value, and every other plain scalar gets loaded as a string. periodt πŸ’š

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);

mwah πŸ’– β€” brought to you by perl v5.42.0, dated 2026-04-24, with the footer title YAML::P...a::JSON(3) doing its lil encore 🫢✨

πŸ“¦ where this page comes from