Add support for max indent level in JSONEncoder.
Improve JSONEncoder to not generate trailing whitespaces.