in reply to Problem printing JSON type output

I would simply use JSON (or JSON::XS), and thereby skate around the entire problem.   If you’ve got a data-structure and you want JSON, or vice-versa, the answer is, “presto!”