JSON.stringify instead of string replacement

Should help against potential future underwater surprises.