> However, the better way is to skip the cheezy `echo "$1" |` in the implementation of json_escape above

This comment made my morning.  Thanks for all the feedback on this stuff, it's exactly what I was hoping for!