Add stringify method

Returns object serialized as a string rather than writing the serialization to a stream as per other methods.