Thread Perl Hash für ein JSON Array sortieren (24 answers)
Opened by cbxk1xg at 2010-10-15 20:03

topeg
 2010-10-15 21:12
#141959 #141959
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Entschuldige, Tippfehler. Ein "$" ist zu viel. So ist es richtig:
Code (perl): (dl )
1
2
use JSON::PP;
my $json_text=JSON::PP->new()->sort_by(sub { $JSON::PP::a cmp $JSON::PP::b })->encode(\%UDIoutput);


EDIT:
Wenn dir die Ausgabe zu kompakt ist, schreib es so:
Code (perl): (dl )
1
2
use JSON::PP;
my $json_text=JSON::PP->new()->pretty->sort_by(sub { $JSON::PP::a cmp $JSON::PP::b })->encode(\%UDIoutput);

Last edited: 2010-10-15 21:17:57 +0200 (CEST)

View full thread Perl Hash für ein JSON Array sortieren