Native JSON loading (was: system module loader)

David Bruant bruant.d at
Thu Mar 8 09:35:32 PST 2012

Le 08/03/2012 18:27, Mike Samuel a écrit :
> mentions
> a system module loader.
> Has the behavior of the system module loader been speced at all?
> If not, would it be worthwhile specifying that when it loads an http
> or https URL, it does so with a fairly minimal Accept header that
> excludes non-script mime-types, especially text/html and */*:
>      Accept: application/javascript;version=next, application/javascript
> or whichever is the preferred mime-type.
I've been using node.js for a couple of month and in node, you can do

     var o = require('myData.json')

The JSON file is parsed automatically. This is very handy for 
configuration files.
I think the heuristic they use to detect a JSON file is the ".json" suffix.
For the web, the content-type would be a far better candidate :-)

Besides node.js, jQuery also has facilities that parse JSON files and 
return an object when the data retrieved from the server has been served 
with application/json.

What about native JSON loading?


More information about the es-discuss mailing list