The from_json method decodes the JSON text that is not UTF-8 encoded to Perl value. This method is provided by the Mojo::JSON module, which provides methods to manipulate JSON.
from_json $json
Here, $json is the JSON string text that is not UTF-8 encoded.
The from_json method returns a Perl hash.
Let's take a look at an example.
In the following example, we try to decode the JSON text that is not UTF-8 encoded and print the returned Perl hash.
# import required packagesuse 5.010;use Data::Dumper;use Mojo::JSON qw(from_json);# given json textmy $json = '{ "comment" : "I ♥ Educative" }';# decode the json textmy $hash = from_json $json;# Print the returned perl valueprint Dumper($hash);
json.json, which is not UTF-8 encoded, using the method from_json. We store it in the hash variable.hash using the Dumper function provided by the Data::Dumper module.