in reply to Create JSON file in specific format
#!/usr/bin/perl use warnings; use strict; use JSON; my $struct = { time => time, id => int rand 65536, }; while (<DATA>) { chomp; my ($key, $value, $format, $version) = split /,/; push @{ $struct->{data} }, { key => $key, value => $value, format => $format, version => $version, }; } my $jsonizer = JSON->new->pretty; print $jsonizer->encode($struct); __DATA__ first,1,1.5.6,5.4 two,2,1.4.6,5.4 five,5,1.5.9,5.1
You might need to use JSON::XS or Cpanel::JSON::XS if speed is important to you.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Create JSON file in specific format
by ovedpo15 (Pilgrim) on Apr 24, 2018 at 15:54 UTC | |
by choroba (Cardinal) on Apr 24, 2018 at 16:13 UTC | |
by AnomalousMonk (Archbishop) on Apr 24, 2018 at 16:09 UTC |