Switch to using JSON. stringify space argument as suggested by @benjaffe