| 1 | package IO::K8s::ApiextensionsApiserver::Pkg::Apis::Apiextensions::V1::JSON; | ||
| 2 | # ABSTRACT: JSON represents any valid JSON value. These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil. | ||
| 3 | 16 | our $VERSION = '1.112'; | |
| 4 | 16 | ▶ | use v5.10; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 16 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 16 | ▶ | use JSON::MaybeXS (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | |||
| 9 | 16 | has value => ( | |
| 10 | is => 'rw', | ||
| 11 | ); | ||
| 12 | |||
| 13 | |||
| 14 | 0 | ▶ | sub _build__json_encoder { |
|
Subroutine
_build__json_encoder: not called CC=1 SCAR=6.9
| |||
| 15 | 0 | return JSON::MaybeXS->new(utf8 => 1, canonical => 1, allow_nonref => 1); | |
| 16 | } | ||
| 17 | |||
| 18 | |||
| 19 | 3817 | ▶ | sub FROM_STRUCT { |
|
Subroutine
FROM_STRUCT: called CC=1 SCAR=0.0
Pod
documented
| |||
| 20 | 3817 | my ($class, $struct, $k8s) = @_; | |
| 21 | # One level, not deeper (k169): the depth IO::K8s::_inflate_struct | ||
| 22 | # copies an untyped value to (k54). _copy_one_level is the role's, | ||
| 23 | # composed into this package by the `with` below and reached unqualified, | ||
| 24 | # as IO::K8s::List does -- IO::K8s::_shallow_copy is the same rule but | ||
| 25 | # would need IO::K8s loaded for a direct FROM_STRUCT call. | ||
| 26 | 3817 | return $class->new(value => _copy_one_level($struct)); | |
| 27 | } | ||
| 28 | |||
| 29 | |||
| 30 | 1123 | ▶ | sub TO_JSON { |
|
Subroutine
TO_JSON: called CC=1 SCAR=0.0
Pod
documented
| |||
| 31 | 1123 | my ($self) = @_; | |
| 32 | # One level (k171), the output side of FROM_STRUCT's copy (k169); | ||
| 33 | # _copy_one_level is the role's, as in FROM_STRUCT above. | ||
| 34 | 1123 | return _copy_one_level($self->value); | |
| 35 | } | ||
| 36 | |||
| 37 | # The node a spec path walks into (IO::K8s::Role::SpecBuilder, k172): the | ||
| 38 | # value itself, the live container rather than TO_JSON's copy, so a write | ||
| 39 | # through the path lands in the object. Free JSON -- no attribute to check | ||
| 40 | # an element against. | ||
| 41 | 53 | ▶ | sub _spec_path_node { return ($_[0]->value) } |
|
Subroutine
_spec_path_node: called CC=1 SCAR=0.0
| |||
| 42 | |||
| 43 | 16 | with 'IO::K8s::Role::Resource'; | |
| 44 | |||
| 45 | 16 | 1; | |
| 46 | |||
| 47 | __END__ | ||