Just tried that but the property keys get surrounded by quotes in the JSON output. I'm not sure if that will make a difference.
| [reply] |
nysus:
It will make a difference, but in a good way, as the JSON format wants keys to be wrapped in quotes: The JSON spec indicates that the object keys are strings, and that strings are wrapped in double quotes. So you should be good to go with the module.
I personally use JSON, which as I understand it, tries to use the first of JSON::XS, JSON::PP or JSON::backportPP that it finds on your machine.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
| [reply] |
my %hash = ( rules => {name => '"required"',
...
Just tried that but the property keys get surrounded by quotes in the JSON output.
The module is just faithfully converting your Perl data structure into a JSON one. Your Perl strings contain the double quotes, so the JSON ones do too. If you don't want that, strip the double quotes from the Perl strings before converting to JSON (or don't add them in the first place).
Update: Sorry, I thought you were talking about the extra quotes in the values, but you meant the keys. See replies below.
| [reply] [d/l] |
Hmm, Data::Dumper gets me very close:
use Data::Dumper;
$Data::Dumper::Pair = ' : ';
$Data::Dumper::Quotekeys = 0;
The keys are not quoted using this method. Only problem now is that the true values are printed as literals with 'true'.
| [reply] [d/l] [select] |