Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-JSON-Parse/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-JSON-Parse/examples/tokenize-synopsis.pl
#!/usr/bin/perl
use warnings;
use strict;
use JSON::Tokenize ':all';
my $input = '{"tuttie":["fruity", true, 100]}';
my $token = tokenize_json ($input);
print_tokens ($token, 0);

sub print_tokens
{
    my ($token, $depth) = @_;
    while ($token) {
	my $start = tokenize_start ($token);
	my $end = tokenize_end ($token);
	my $type = tokenize_type ($token);
	print "   " x $depth;
	my $value = substr ($input, $start, $end - $start);
	print ">>$value<< has type $type\n";
	my $child = tokenize_child ($token);
	if ($child) {
	    print_tokens ($child, $depth+1);
	}
	my $next = tokenize_next ($token);
	$token = $next;
    }
}

Hry