Hello members,
I am new to json. I know it is key value pair, and that is it.
I am using language-Perl.
What is encode, decode in it? Why do we require?
my output is:
Questions:
1- when should I use hash for initiating json?
2- I want to print output as
{
"trans1": [20,30]
}
This is the output I want in a new file. So is it a encoded one or decoded one? I will read this output from a python a script.
Also, there is tonnes of info on utf-8 for Json, I couldn't get much on that.
Please guide me here.
I am new to json. I know it is key value pair, and that is it.
I am using language-Perl.
What is encode, decode in it? Why do we require?
Code:
use strict; use autodie; use Data::Dumper; use IO::File; use warnings; use JSON::PP; my %rec_hash = ('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5); my $json = encode_json \%rec_hash; print "$json\n"; my $son = '{ "trans1": [20,30] }'; print $son;
{"e":5,"c":3,"a":1,"b":2,"d":4}
{
"trans1": [20,30]
}
{
"trans1": [20,30]
}
1- when should I use hash for initiating json?
2- I want to print output as
{
"trans1": [20,30]
}
This is the output I want in a new file. So is it a encoded one or decoded one? I will read this output from a python a script.
Also, there is tonnes of info on utf-8 for Json, I couldn't get much on that.
Please guide me here.
Comment