Phonegap read and write json file

I want to store a JSON file locally on IOS / Android in a Phonegap application (Cordova).

Basically, I am extracting the JSON file from the server ($ .GETJSON), and I want to save the JSON file first, and then extract and modify it.

I looked at FileWriter but can't see mimetype ... the only example gives text files.

Thanks in advance!

Nick

+5
source share
2 answers

, FileWriter.write, JSON . JSON - , mime. , FileReader.readAsText. "onloadend" FileReader , event.target.result JSON-.

var myJson = JSON.parse(event.target.result);

JSON.

+13

( ) , - , :

(function(){
angular.module('app').constant('settings_json', 
{  
    "name":"settings",
    "data":[  
       {  
          "set":"globals",
          "share_diagnostics":true,
          "user_prefs_save_cloud": true         
       },
       {
          "set":"user",
          "fname":'',
          "lname": '',
          "telephone": '',
          "email": ''       
       }
    ]
}
)})();

: ( "settings_json" )

var settings = angular.fromJson(settings_json);
+2

All Articles