1

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 Answer 1

11

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);
  });
Sign up to request clarification or add additional context in comments.

6 Comments

How to store JSON from api? example from here randomuser.me/api
Just access your rest API using HTTP and then store the result as shown above. What is the issue here?
Ok i'll try. Sorry i'm new to ionic
OK, sure. If you have any issue please let us know.
Yes, you can. But I highly recommend using Ionic Caching Service module if you need to work on the offline use case. Since it has a lot of features. ionicacademy.com/ionic-caching-service
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.