Re: [w3c/webcomponents] HTML, CSS, and JSON modules shouldn't solely rely on MIME type to change parsing behavior (#839)

Presumably the reviver function was added to JSON.parse, because it allows for a more efficient way of doing things like converting date strings to dates while parsing, rather than having to do so on a second pass.

The argument may not have carried as much weight in the case of fetch, since response.text() was (and is) available.

However, since importing JSON as text isn't an option (maybe it should be?), the reviver option seems more applicable.

Or maybe importing as text should be an option?  So now we are back to supporting both:

```JavaScript
import doc from "./foo.json" as string;
```

and 

```JavaScript
import doc from "./foo.json" as json;
```

, another example of what @justinfagnani was alluding to.

Both options (as string/json or with reviver) seem preferable to:

```JavaScript
import doc from "./foo.json" with noexecute;
```

but not enough, in my mind to freeze progress on importing data in various forms. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/839#issuecomment-549141135

Received on Sunday, 3 November 2019 14:21:09 UTC