How to use Ionic Storage to store json object from api with ionic 3?

老子叫甜甜 提交于 2019-12-23 04:22:49

问题


I would like to know how to use Ionic Storage to store Json Object with Ionic 3. I am finding it difficult as there are no examples for the ionic 3 and i am stuck. Nothing on the net seems to be updated. A supporting example for Ionic Storage would be of great use. Thank you in advance.


回答1:


Yes, you can store JSON objects in Ionic storage.

  let your_json_object = { "name":"John", "age":30, "car":null };

  // set a key/value
  storage.set('my-json', your_json_object);

  // to get a key/value pair
  storage.get('my-json').then((val) => {
    console.log('Your json is', val);
  });


来源:https://stackoverflow.com/questions/46217643/how-to-use-ionic-storage-to-store-json-object-from-api-with-ionic-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!