Skip to main content
100%

Gist 30cbfbfa6a3cb42eef6beba8d35b62a1

✓ Published0🌍 Public
Aalexfinnarn
Last edited Oct 25, 2018
Created on Oct 25, 2018

This example demonstrates a browser-based utility for saving JSON data as a downloadable file. It shows how to serialize a JavaScript object into a formatted JSON string, wrap it in a Blob, and trigger a client-side download. The code uses the Blob constructor with the `application/json` MIME type, feature-detects the HTML5 `download` attribute, and creates a temporary anchor element with `URL.createObjectURL` to initiate the download. It also includes a fallback for Internet Explorer 10+ using `navigator.msSaveBlob`. The filename is fixed as `directory.json`, and the data structure comes from the `finalData` parameter passed to the `downloadFile` function.

AI-generated description

Similar vizzes