* Chase Whitener ([email protected]) [141216 16:17]:
> Sorry about that, I could have provided a more useful link to where the
> conversation started: http://irclog.perlgeek.de/mojo/2014-11-27#i_9730172
> >
> > perl -Mojo -E 'my $true_scalar = "1"; my $false_scalar = "0"; say j([1,
> > "1", \1, Mojo::JSON->true, \$true_scalar, 0, "0", \0, Mojo::JSON->false,
> > \$false_scalar])'
> >
> > perl -Mojo -E 'say j([1, \1, Mojo::JSON->true])'

I think this leads to a clean interface:

  package My::Clean::Interface;

  my @boolean_fields = qw/is_success need_more/;
  my (@float_field, @int_fields);

  sub send_data($)    # extern we do not tell in which format
  {   my $data = Data::Dumper::DeepCopy(shift);

      $data->{$_} = $data->{$_} ? JSON::true : JSON::false
          for @boolean_fields;

      $data->{$_} += 0
          for @float_fields, @int_fields;  # avoid "3.14"

      print json_encode $data;
  }
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net


_______________________________________________
Xml-compile mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile

Reply via email to