alf (red_alf) wrote,
alf
red_alf

JSON из Data::Dumper

Берем Data::Dumper, добавляем
$Data::Dumper::Terse=1;
$Data::Dumper::Pair=" : ";
и получаем JSON на выходе. Мелочь, но приятно. Может пригодится :)



perl -MData::Dumper -le '$js = {arr => [1,2,3], str => "hello", obj => {field => "something"}}; $Data::Dumper::Terse=1; $Data::Dumper::Pair=" : "; print Dumper($js)'
{
          'obj' : {
                     'field' : 'something'
                   },
          'str' : 'hello',
          'arr' : [
                     1,
                     2,
                     3
                   ]
        }

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments