Yeah, I can't help but wonder if somewhere deep in this question we could make use of Boosts ptree "pretty" representations. I actually had the opposite problem recently, and I wonder if we couldn't add a SQL 'json' or 'pretty' function that would render the json as you're wanting