[TriLUG] Perl substitution problem
Lance A. Brown via TriLUG
trilug at trilug.org
Sat Jun 17 01:18:21 EDT 2017
Not the answer to the question you are asking, but I'd advise not
hand-generating JSON. Just build the data structure you need in perl
and convert it.
$ cat t.pl
#!/usr/bin/perl
use JSON;
my $data = {
'string1' => 'this "should" work',
'string2' => 'this "should"*,* work'
};
my $json_string = encode_json($data);
print $json_string, "\n";
$ perl t.pl
{"string1":"this \"should\" work","string2":"this \"should\"*,* work"}
JSON is great, but it's a pain in the ass to generate manually. Why
bother when JSON and JSON::PP ship as part of core perl these days.
--[Lance]
More information about the TriLUG
mailing list