Vue.js - Watch changes in JSON file

Solution 1:

Its not possible to watch for changes inside a json file. What you could do is set the json to a reactive property and check for changes on there. When changing the JSON you also need to update the reactive property so the watcher gets triggered

new Vue({
  el: "#app",
  data: {
   content: ''
  },
  watch: {
    content: function (val) {
      // do something when content has changed
    },
    },
  methods: {
    importJson() {
            // import json and set contents to content
    },
    saveJson(newJSON) {
        this.content = newJSON
      // Somehow save the json data to the json file
    }
  }
})

You should now that changes to a JSON file are not persistent.