Am making an hybrid mobile app and i need to store some of the data like for example if its a game : the high score etc .. so far am able to read data from JSON file using jquery .., but is it possible to write to JSON file ??!
Or is there any other way to do so ?
IDE - Eclipse ( plugin - IBM worklight studio )
Only HTML 5 and JS and JQ can be used !
Thanks (:
You can write JSON into local storage and just use JSON.stringify (non-jQuery) to serialize a JavaScript object. You cannot write to any file using JavaScript alone. Just cookies or local (or session) storage.
var obj = {
name: 'Dhayalan',
score: 100
};
localStorage.setItem('gameStorage', JSON.stringify(obj));
And to retrieve the object later, such as on page refresh or browser close/open...
var obj = JSON.parse(localStorage.getItem('gameStorage'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With