The method I needed is
JSON.stringify(), and it’s very easy to use.
var text = JSON.stringify(myObject);
The above example serialises myObject into text.
There is an equivilant method,