Perl: Fix JSONization of ArrayObjects (#12896)

* Perl: fix object to json

* generate samples

* add test case
This commit is contained in:
AnaTofuZ 2022-07-17 13:50:39 +09:00 committed by GitHub
parent 0b80444b56
commit 75895e18bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 114 additions and 2 deletions

View File

@ -111,6 +111,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -161,6 +161,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -161,6 +161,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -155,6 +155,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -152,6 +152,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -153,6 +153,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -151,6 +151,8 @@ sub _to_json_primitives {
return $data->rfc3339;
}
return $data .q();
} else { # hash (model), In this case, the TO_JSON of the $data object is executed
return $data;
}
}

View File

@ -1,4 +1,4 @@
use Test::More tests => 52;
use Test::More tests => 56;
use Test::Exception;
use lib 'lib';
@ -170,4 +170,18 @@ like $order_to_json, qr/2020-11-06T09:20:48Z/, '$order{shipDate} to date-time fo
like $order_to_json, qr/"101112"/, '$order{status} is number. But json type is string';
like $order_to_json, qr/false/, '$order{complete} is number. But json type is boolean';
like $order_to_json, qr/false/, '$order{complete} is number. But json type is boolean';
my $pet_object = WWW::OpenAPIClient::Object::Pet->new->from_hash({
tags => [
WWW::OpenAPIClient::Object::Tag->new->from_hash({id => 123, name => 1000}),
WWW::OpenAPIClient::Object::Tag->new->from_hash({id => 456, name => 'test2'}),
]
});
my $pet_object_to_json = JSON->new->convert_blessed->encode($pet_object);
like $pet_object_to_json, qr/\"id\":123/, '$pet_object->tags->[0]->id';
like $pet_object_to_json, qr/\"name\":\"1000\"/, '$pet_object->tags->[0]->name';
like $pet_object_to_json, qr/\"id\":456/, '$pet_object->tags->[1]->id';
like $pet_object_to_json, qr/\"name\":\"test2\"/, '$pet_object->tags->[1]->name';