- From: Zoltan Kis via GitHub <sysbot+gh@w3.org>
- Date: Wed, 12 Aug 2015 15:57:53 +0000
- To: public-web-nfc@w3.org
I have been talking with implementors who say it is too complex with two properties for type and that is right. All underlying platforms expose just (MIME) type and data. So let's see if we can merge the two, case by case (just thinking out loud). A. Mapping for writes 1. Writing text: ```data``` = "any text", allowed ```type``` is "text", or "text/plain", or any valid MIME type "text/*anything*". Otherwise reject. Implementations map it to an NDEF record with TNF = 1 Type Text. 2. Writing URL: ```data``` = "http://valid.url", allowed ```type``` is "url", or "text/uri-list". Otherwise reject. Implementations map it to TNF=1 Type URI. 3. Writing JSON: ```data``` = null || *number* || *string* || *Object*, allowed ```type``` is "json" or "application/json". Otherwise reject. Implementations map it to TNF=2 with MIME type "application/json". 4. Writing ```data``` with JS type *ArrayBuffer*, or *string*, or *Object* with ```type``` = *valid_MIME_type* will result in mapping to TNF=2 with the given MIME type (and it will read back as *ArrayBuffer*, see B.4.). B. Mapping for reads 1. TNF=1 Type Text is presented as ```type``` = "text", ```data``` = "string". 2. TNF=1 Type URI, TNF=1 Type Smart Poster, and TNF=3 Absolute URI is presented as ```type```="url", ```data``` = "string". 3. TNF=2 when MIME type is "application/json" is presented as ```type``` = "json", ```data``` = either *null*, or a *number*, or a *string*, or an *Object*. 4. TNF=2 with other MIME types are presented as ```type``` = *MIME_type*, ```data``` = *ArrayBuffer*. 5. TNF=4 with type other than ```urn:nfc:ext:w3.org:webnfc```, and any other NDEF record type is presented as ```type``` = "opaque", ```data``` = *ArrayBuffer*. So it seems that my earlier (theoretical) concerns about losing type information are not valid and in practice we could merge the type properties (<*chastising self*>): ```webidl dictionary NFCRecord { USVString type; // "url", "text", json", "opaque", or a MIME type any data; }; dictionary NFCMessage { USVString scope; sequence<NFCRecord> data; }; ``` Would this work? -- GitHub Notif of comment by zolkis See https://github.com/w3c/web-nfc/issues/26#issuecomment-130354747
Received on Wednesday, 12 August 2015 15:57:55 UTC