toJSON
The toJSON() method of the Device interface is a serializer;
it returns a JSON representation of the Device object.
To get a JSON string, you can use JSON.stringify(device) directly; it will call toJSON() automatically.
Syntax
toJSON()
Return value
A JSON object that is the serialization of the Device object.