Writes provided json to string.
If pretty is set to true new lines and whitespaces will be added to output.