Great point! But what if you’re working in a browser and want to automate reading the file—without user uploads? I’ve had this come up often when working with mock APIs and dev servers. If you can serve your JSON via HTTP (like from a public folder or an API endpoint), then the fetch API is super handy for a javascript read json file scenario.
fetch('test.json')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Fetch error:', error));
Just be sure the file is accessible from the same origin—or handle CORS if it’s from another domain. It’s a clean, async way to fetch and use JSON data right inside the browser.