Re: [web-nfc] What's the value of `toJSON()`? (#366)

There's some precedent here with [push bodies](https://developer.mozilla.org/en-US/docs/Web/API/PushMessageData).

If you're going to add this, the naming should align with push (and fetch). This is especially important as [`toJSON` already has meaning on the platform](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description).

The benefit of `response.json()` is the platform can parse it in a streaming manner. That isn't really true here or push, since the amount of data is really small & synchronously available.

If it's common to get the data as text, then a helper method seems reasonable (and that should be named `.text()`). Then I guess you may as well add the rest for consistency. Although I don't think I'd be arguing for that if push hadn't set precedent.

-- 
GitHub Notification of comment by jakearchibald
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/366#issuecomment-540982887 using your GitHub account

Received on Friday, 11 October 2019 09:07:02 UTC