In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to convert json data into demo.json and download files". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to convert json data into demo.json and download files.
Json is treated as a string and can be downloaded using DataURL
Text-> DataURL
In addition to using DataURL, you can also convert it to Object URL for download
Text-> Blob-> Object URL
You can paste the following code directly into the console download file
Function download (url, name) {
Const a = document.createElement ('a')
A.download = name
A.rel = 'noopener'
A.href = url
/ / trigger simulation click
A.dispatchEvent (new MouseEvent ('click'))
/ / or a.click ()
}
Const json = {
A: 3
B: 4
C: 5
}
Const str = JSON.stringify (json, null, 2)
/ / solution 1: Text-> DataURL
Const dataUrl = `data:,$ {str} `
Download (dataUrl, 'demo.json')
/ / option 2: Text-> Blob-> ObjectURL
Const url = URL.createObjectURL (new Blob (str.split (')
Download (url, 'demo1.json') summary simulation download, you can create a new tag and set the url and download attributes to download can convert json to dataurl to construct URL can convert json to Blob and then convert to ObjectURL to construct URL to this, I believe that everyone on the "how to convert json data into demo.json and download files" have a deeper understanding, might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.