browser

How to download a json file from url


I am solving mongodb tutorials from mongodb university. Their website has a link called "download homework". When I click on the link, nothing gets downloaded, instead the json file intended to be downloaded is displayed on a webpage with url like https://somepath.json.

My question is how to download a json file when you have the URL pointing to it?


Solution

  • First of all, it depends on what operating system you're using.

    On Windows

    If you right click and press "save" (Alternatively use ctrl-s) and then chose the file format "json" when saving.

    On macOS

    You can do this in a few ways, I'd suggest using curl. You'd do this by opening the terminal and navigating to the directory you'd like to download the file to. Then enter the following:

    curl https://somedomain.com/somepath.json > fileName.json
    

    This will download the file in its original format.