How can I import JSON in ECMAScript 6?

You can use dynamic import() to load modules or resources like JSON files asynchronously at runtime. For example:

const config = await import('./config.json', {
  assert: { type: 'json' }
});
console.log(config.default);

:white_check_mark: Why use this:

Works in modern environments (Node ≥17.5 with flags, browsers with module support)

Useful for conditional or dynamic imports