JSON is pretty easy so you probably won’t see tutorials on it here. It’s also not Perl; tutorials abound elsewhere. If it doesn’t feel easy, slow down. It’s not magic. It’s just plain data notation, extremely similar to data structures in Perl (mostly just anonymous hashes and arrays). It’s also arbitrarily loaded. You can’t make assumptions like “label” or “titlecase.” It’s not meaningful in JSON, just in this particular data structure. This is JSON: [ 1, 2, 5, "Three, Sire!" ]. So is this: { "o":"hai", "name-o":"બિન્ગો" }. It’s easy to play with–
perl -CSD -MYAML -MJSON -e 'print Dump(decode_json(shift))' '{ "name-o":"બિન્ગો" }'
---
name-o: બિન્ગો
perl -MYAML -MJSON -e 'print Dump(decode_json(shift))' '[ 1, 2, 5, "Th +ree, Sire!" ]' --- - 1 - 2 - 5 - 'Three, Sire!'
Like any well-defined format it should be handled with a proper parser and writer and not regular expressions. JSON docs are just waiting to be read. :P
Update, fixed typo/drift in code output.
In reply to Re^4: the sad reality of perl
by Your Mother
in thread the sad reality of perl
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |