Handle the output of complex data structures ready for JSON output