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.

Local JSON support related

See original GitHub issue

Some people have requested local JSON feature. I have some concerns on this. But I also see some benefits. And overall, I think it’s worth discussing.

Possible solutions

There can be two solutions to this:

Approach 1. OPEN THE FILE DIRECTLY

Just use the internal method to directly open a JSON file from the bundle and draw it to the view.

Approach 2. SET UP AN IN-APP WEB SERVER

Set up an in-app web server and serve local files through the web server. (You could access them using something like local:// or localhost:// or something like that) This may sound convoluted compared to Approach 1, but I think it’s interesting in its own way. More on this below.

Current status

There have been a couple of pull requests for this. I took a look at them and categorized them into these categories:

  1. Approach 1

  2. Approach 2

Benefits

The obvious benefit is you can run your app offline. This is great, and some people have asked for this. Also you can quickly develop locally if you have a local JSON.

Concerns

My concern is just that I wasn’t envisioning this kind of usage when I was building Jasonette. It may look like just an innocent little feature, but I think it may have larger implication than that, going forward.

Until now Jasonette has been fully cloud based, therefore easy to understand–You simply add a URL and you have an app.

However once we support this, we have no reason not to support all kinds of other offline features. So it’s not just a matter of “let’s add this little feature”, we will need to commit to this direction. With the current thin client approach, we can easily scale to other platforms since everything is cloud based, but starting to support local may mean this may be difficult. (Then again, even desktop web browsers have localhost features, so maybe it’s workable, i don’t know) But this is just my opinion based on my gut feeling. That’s why I would love to hear thoughts.

Questions & Discussion

  1. I do think we may need to support this local feature at some point. It’s just a matter of whether we should do it now or not. What are your thoughts on “support local now” vs. “think about it later”? Maybe it’s worth a try to support it now and see how it goes?

  2. The web server approach by @copongcopong caught my interest because this feels like it could enable many other types of usage for Jasonette. Serving local files is just one usage, but what excites me is when you have a web server running, you can serve to the outside world as well. I like to imagine things so I could think of some weird and exciting use cases. I don’t know yet what this would mean but I feel like there’s something there. Any thoughts on this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
jdrydncommented, Nov 16, 2016

Why not implement offline-caching?

  • If an Internet connection is available, fetch the JSON at the URL and cache the file
  • Else if we have a cached file (from an earlier run) then use that
  • Else use an offline version in the app

This requires people to either include “the latest version of the JSON file” in their app during app-updates or leave a pre-written JSON file with a “Sorry please go online” view. Either way, I think this sticks to the original principles 😉

3reactions
gliechtensteincommented, Nov 17, 2016

@jdrydn @jereze Today’s your lucky day guys. Try adding {"offline": "true"} to head:

{
  "$jason": {
    "head": {
      "offline": "true"
    }
  }
}

This is one of those undocumented features I didn’t have enough time to test so didn’t add to the documentation but actually works fine.

Please try it out and let us know 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Local JSON - ACF
Local JSON is a new feature added in version 5 which saves field group and field settings as .json files within your theme....
Read more >
3+ Ways for Reading Local JSON Files with Angular 15
In this post, we'll show you three different methods to read local JSON files in your Angular 15 application, each with an example....
Read more >
Power Query JSON connector - Microsoft Learn
Load a local JSON file from Power Query Desktop​​ To load a local JSON file: Select the JSON option in the Get Data...
Read more >
ETL to Local JSON files | Open-source Data Integration - Airbyte
The Airbyte Local JSON ELT data integration destination connector will replicate your data from APIs, databases and files to Local JSON files.
Read more >
JavaScript Tip: Loading a Local JSON File without Fetch
Loading a local JSON file is frequently done with fetch. But that is not the only way to accomplish this. In this tutorial...
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