久久久久久久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í)的歡迎消息)
主站蜘蛛池模板: 国产91在线 | 亚洲 | 亚洲视频一区在线观看 | 国产精品久久一区二区三区 | 日本一区二区在线视频 | 亚洲一区国产精品 | 欧美视频在线看 | 久久中文字幕一区 | 欧美精品乱码久久久久久按摩 | 欧美成人精品一区二区男人看 | 亚洲网站在线观看 | 国产精品69毛片高清亚洲 | 久久久久国产精品一区 | 免费视频一区二区 | 精品国产一区二区在线 | 亚洲一区二区三区免费在线 | 国产精品久久久久久福利一牛影视 | 国产精品一区二区久久精品爱微奶 | 欧美综合久久久 | 中文在线观看视频 | 毛片一区二区三区 | 亚洲a视频 | 亚洲精品一级 | 国产中文字幕在线观看 | 美国一级黄色片 | 欧美成人aaa级毛片在线视频 | 国产在线精品一区 | 欧美一区二区三区在线观看 | 国产精品精品久久久 | 中文字幕亚洲精品 | 五月综合激情在线 | 久久精品一区二区三区四区 | 日本久久精品 | 狠狠婷婷综合久久久久久妖精 | 欧美最猛黑人xxxⅹ 粉嫩一区二区三区四区公司1 | 亚洲精品粉嫩美女一区 | 97国产精品 | 成人精品一区亚洲午夜久久久 | 国产精品自拍一区 | 欧美激情综合 | 日韩五月天 | 欧美乱做爰xxxⅹ久久久 |