# JSON ```bash sudo cpanm JSON ``` [JSON - JSON (JavaScript Object Notation) encoder/decoder - metacpan.org](https://metacpan.org/pod/JSON) ## 문자열을 해시로 변환 ```perl #! /usr/bin/perl use strict; use JSON; my $json = <{'name'}\n"; print "AGE: $obj->{'age'}\n"; ``` `decode_json`은 매개변수로 문자열을 전달받고, 변환 결과인 해시에 대한 참조를 반환합니다. ## 해시를 문자열로 변환 ```perl #! /usr/bin/perl use strict; use JSON; my %person = ('name'=>'Steve', 'age'=>34); my $text = &encode_json(\%person); # pass a reference to a hash print "JSON TEXT: $text\n"; ``` `encode_json`은 해시에 대한 참조를 매개변수로 전달 받고, 변환 결과를 문자열로 반환합니다.