Json merge prettyencoder and encoder

@alexcrichton as per https://github.com/rust-lang/rust/pull/12936#issuecomment-37782264
removing ToJson is the next step.

this PR requires #19490 to be merged first, so ignore the first commit on this PR