Understanding JSON file and local storage in app


#1

I would like to verify my understanding on dealing with JSON

The current best practice is to fetch JSON from a remote server and use some plugin to save it into SQLITE.

A simpler way was to store in localstorage, but it sound less reliable, do i get it right?

Then, is it possilble to just pull the entire .JSON file and save as .JSON locally and then simply read the file as if it is locally packaged into the app:
this.http.get(‘localdatapath/data.json’).subscribe(res => {
this.data = res.json();
resolve(this.data);
console.log(this.data);
});

is it possible?


#2

Yaa It is very easily possible, but you have too use pouchDB rather then SQLIte…


#3

You can store your json as text (res.text()) and then parse it (JSON.parse(data)) to get your JSON back :wink:

You can use ionic storage (simple key/value storage, websql on a browser and sqlite on devices) or SQLite.