Rename the to_*json functions.

They write data to a stream, so new names better explain the purpose of the functions.
Functions to_json and to_pretty_json.

These ones return string with JSON.