in reply to Re^5: Size of a HASH (with more keys)
in thread Size of a HASH (with more keys)

I am trying to find a step by step guide on how to do the JSON encode using CPAN's module. In their library I know it's descriptive.

But I as I read it quickly, I think they generate only JSON (which is a bit different than JSONP).

Nevertheless, so If I have a HASH where all the info is stored that I want. How should I create a JSONP with this Module?

$json_text   = $json->encode( $perl_scalar );

This is the syntax from CPAN. Is the $perl_scalar my $testHASH in our case?

Replies are listed 'Best First'.
Re^7: Size of a HASH # Perldsc vs JSON
by LanX (Saint) on Jul 02, 2014 at 14:28 UTC
    > (which is a bit different than JSONP).

    try reading JSONP and explain the difference. You might figure out how to use JSON then! (hint: + padding)

    > Is the $perl_scalar my $testHASH in our case?

    from JSON

    $json_text = to_json($perl_scalar) Converts the given Perl data structure to a json string.

    If you try to understand JSON and Perl Data Structures you will see that they have the exactly same structure with little syntactic differences (enough to justify a module in that case)

    I.o.w. $perl_scalar is a ref to a HoH or HoA or AoH (... and so on) reflecting the JSON structure you desire.

    Please try ...

    • to read the links I gave you,
    • use search engines for example code
    • generally try experimenting with code¹
    ... to improve your coding skills.

    Hope this helped! :)

    Cheers Rolf

    (addicted to the Perl Programming Language)

    update

    ¹) use Data::Dumper or Data::Dump to inspect data structures