From 4aea02e1e152b97242dba77985b70c53a666b012 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 26 Apr 2021 16:00:57 -0700 Subject: [PATCH] ToJSON: serialize boolean_columns to JSON boolean --- src/lib/Hydra/Component/ToJSON.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/Hydra/Component/ToJSON.pm b/src/lib/Hydra/Component/ToJSON.pm index ed8d59d9..f6920943 100644 --- a/src/lib/Hydra/Component/ToJSON.pm +++ b/src/lib/Hydra/Component/ToJSON.pm @@ -5,6 +5,7 @@ use strict; use warnings; use base 'DBIx::Class'; +use JSON; sub TO_JSON { my $self = shift; @@ -17,6 +18,10 @@ sub TO_JSON { $json{$column} = $self->get_column($column); } + foreach my $column (@{$hint->{boolean_columns}}) { + $json{$column} = $self->get_column($column) ? JSON::true : JSON::false; + } + foreach my $relname (keys %{$hint->{relations}}) { my $key = $hint->{relations}->{$relname}; $json{$relname} = [ map { $_->$key } $self->$relname ];