question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to read json file in static oder assets folder

See original GitHub issue

Hi,

i tried to read an json file with my configurtion, but I can`t get the path to the assets or static folder. How can I do that?

regards

import path from 'path'
import { remote } from 'electron'

console.log("getAppPath:", remote.app.getAppPath())
const jsonPath = path.join(remote.app.getAppPath(), '/assets/content.json')
console.log(jsonPath);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
lbeniecommented, Jan 17, 2018

simply require the file

const json = require("../assets/content.json")
2reactions
neumancommented, Aug 22, 2020

@SimulatedGREG am I missing some doc somewhere which explains how to make __static work? It is undefined in App.vue, background.js, and everywhere else I try. I cannot find any reference to it in my project folder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - How can I parse a local JSON file from assets folder into ...
First of all read the Json File from your assests file using below code. and then you can simply read this string return...
Read more >
Java Android - Read JSON file from assets using Gson
You will need to create the assets folder inside src/main, together with java and res folder. Then put JSON file inside assets folder....
Read more >
Node.js Tips — Read JSON, Serve Static Files, Sorting File ...
We use the express.static middleware to serve static files. Then we can access them from index.html , where we access the assets folder....
Read more >
How to import Static Json File from assets folder in Angular in ...
... How to Import static json file in service from assets folder in AngularJoin this channel to get access to perks:https...
Read more >
Read A JSON File From Assets in Angular - Better Programming
One way to read a JSON file from the assets folder in Angular is to use the import statement in your component. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found