Might be a misconception of JavaScript import
statement.
It's used to import files in JavaScript syntax.
The prefixed @
in path is most likely Webpack's resolve.alias
which is a stand-in for your source folder. As such the @
alias is configured by Vue for example.
JSON import using a module loader
So when importing a JSON file like this using Webpack (as configured by Vue):
import myObject from "@/myObject.json";
You can immediately and directly use it, like any other JavaScript object previously defined:
const keys = Object.keys( myObject );
console.log( keys );
No parsing required, because this has already be done by import
.
See also:
How to import a JSON file in ECMAScript 6?
Loading JSON in vanilla JS
In plain vanilla JavaScript you have to load the JSON via XMLHttpRequest
and parse it or jQuery offers convenient function:
$.getJSON("test.json", function(json) {
console.log(json);
var myObject = JSON.parse(json);
});
See also:
Loading local JSON file