Thread use mit Schalter mit require formulieren (5 answers)
Opened by bianca at 2016-12-01 10:02

Linuxer
 2017-04-30 11:53
#186420 #186420
User since
2006-01-27
3870 Artikel
HausmeisterIn

user image
Verwende direkt CPAN:JSON::PP.

Siehe CPAN:JSON.
perldoc JSON
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$JSON::KeySort

$json->canonical->encode($perl_scalar)

This is the ascii sort.

If you want to use with your own sort routine, check the sort_by method.

(Only with JSON::PP, even if -support_by_pp is used currently.)

$json->sort_by($sort_routine_ref)->encode($perl_scalar)

$json->sort_by(sub { $JSON::PP::a <=> $JSON::PP::b })->encode($perl_scalar)

Can't access $a and $b but $JSON::PP::a and $JSON::PP::b.


Speziell die Zeilen 7 und 9 sind bemerkenswert.
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread use mit Schalter mit require formulieren