You may find this useful once you get your JSON back from the legend url. [Ripped off from the old 3.x\digit]
/// Key Line
/// src = "data:image/png;base64," +
this.rootLayerTOC._legendResponse.layers[this.rootLayer.layerId].legend[0].imageData;
///
_getLegendIconUrl: function(legend) {
var src = legend.url;
if (src == null) {
src = "data:image/png;base64," +
this.rootLayerTOC._legendResponse.layers[this.rootLayer.layerId].legend[0].imageData;
} else if (src != null && src.indexOf('data') == -1) {
// in some cases NULL value may cause #legend != #of renderer entry.
if (!has('ie') && legend.imageData && legend.imageData.length > 0) {
src = "data:image/png;base64," + legend.imageData;
} else {
if (src.indexOf('http') !== 0) {
// resolve relative url
src = this.rootLayer.url + '/' + this.serviceLayer.id + '/images/' + src;
}
if (this.rootLayer.credential && this.rootLayer.credential.token) {
src = src + "?token=" + this.rootLayer.credential.token;
} else if (esriConfig.defaults.io.alwaysUseProxy) {
src = esriConfig.defaults.io.proxyUrl + "?" + src;
}
}
}
return src;