久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Electron 中保存 JSON

Saving JSON in Electron(在 Electron 中保存 JSON)
本文介紹了在 Electron 中保存 JSON的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在使用 Electron 構(gòu)建一個(gè)應(yīng)用程序.在這個(gè)應(yīng)用程序中,我正在使用 JSON 構(gòu)建數(shù)據(jù)結(jié)構(gòu).我的數(shù)據(jù)結(jié)構(gòu)如下所示:

I am building an app using Electron. In this app, I am building a data structure using JSON. My data structure looks like this:

{
  items: [
    { id:1, name:'football' },
    { id:2, name:'soccer ball' },
    { id:3, name:'basketball' }
  ]
}

我想將此 JSON 保存到名為data.json"的文件中.我想將其保存到文件中,因?yàn)槲蚁朐谙麓螒?yīng)用程序啟動(dòng)時(shí)加載.我的挑戰(zhàn)是,我不知道如何保存數(shù)據(jù).事實(shí)上,我什至不確定應(yīng)該將文件保存在 哪里.我是否將其保存在與應(yīng)用程序相同的目錄中?或者我應(yīng)該使用一些跨平臺(tái)的方法嗎?

I want to save this JSON to a file called "data.json". I want to save it to a file because I want to load the next time the application starts. My challenge is, I do not know how to save the data. In fact, I'm not sure where I should even save the file. Do I save it in the same directory as the app? Or is there some cross-platform approach I should use?

目前,我有以下內(nèi)容:

saveClick: function() {
  var json = JSON.stringify(this.data);
  // assume json matches the JSON provided above.
  // Now, I'm not sure how to actually save the file.
} 

那么,我如何/在哪里將 JSON 保存到本地文件系統(tǒng)以供以后使用?

So, how / where do I save JSON to the local file system for use at a later time?

推薦答案

Electron 缺乏一種簡(jiǎn)單的方法來(lái)持久化和讀取應(yīng)用程序的用戶設(shè)置.electron-json-storage 實(shí)現(xiàn)了一個(gè)類似于 localStorage 的 API根據(jù) app.getPath('userData') 的定義,在操作系統(tǒng)應(yīng)用程序數(shù)據(jù)目錄中寫(xiě)入和讀取 JSON 對(duì)象.

Electron lacks an easy way to persist and read user settings for your application. electron-json-storage implements an API somehow similar to localStorage to write and read JSON objects to/from the operating system application data directory, as defined by app.getPath('userData').

這篇關(guān)于在 Electron 中保存 JSON的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來(lái)加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來(lái)自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 久久久一二三区 | 超碰在线影院 | 97福利在线| 91偷拍精品一区二区三区 | 福利视频一区 | av在线一区二区三区 | 国产一区二区 | 国产在线一区二 | 五月免费视频 | 久久高清 | www.99热.com| 色婷婷综合在线观看 | 精品国产一区二区三区久久久久久 | 国产99久久精品一区二区永久免费 | 欧美日韩精品一区二区 | 99re在线播放 | 三级av在线| 国产又色又爽又黄又免费 | 成人免费av在线 | 免费看国产精品视频 | 国产一区免费视频 | 日本不卡一区二区三区在线观看 | 一级片成人 | 欧美日本在线观看 | 国产成人a亚洲精品 | 毛片一级网站 | 成人免费观看男女羞羞视频 | 国产成人免费视频 | 一级片网址 | 亚洲美女一区二区三区 | 久久久精彩视频 | 国产一级在线 | 免费黄色a视频 | 中文字幕一区二区三区日韩精品 | 国产欧美在线一区 | 久久久久久中文字幕 | 国产黄色免费网站 | 欧美成人激情 | 99av成人精品国语自产拍 | 亚洲精品一区中文字幕乱码 | 久久精品国产亚洲 |