As far as I know, there is nothing in v. 3.x of the JavaScript API to generate json for a web map, and it is not a trivial task to do it yourself. It is supposed to be a feature of the 4.0 API, but as of Beta 1, it is not available yet.
Also, I suspect the PrintTask is generating an Export Web Map, which is slightly different. According to Esri documentation on the ArcGIS web map format:
"The web map and its specification should not be confused with the ExportWebMap specification, which is used by ArcGIS Server when printing maps. Although you may notice similarities in properties, they are two different specifications."
Mike