Notify me of new comments via email. Notify me of new posts via email. Follow following steps to save and retrieve JSON data in local storage. Step 1 Right click on project and add Nuget package and add package of Json. Step 2 Let us assume that we need to store Student information in local storage. CreateFileAsync "a. We are reading student properties from various textboxes. GetFileAsync "a. Size; await textReader.
Name; txtCity1. Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 6 years, 9 months ago. Active 3 years, 1 month ago. Viewed 22k times. Do you have any experience how to do that? Improve this question. Honey Add a comment. Active Oldest Votes. Great question! I think you have two approaches to fetching the JSON. That would look something like the following: Alamofire. Improve this answer. Thanks for answer! Only possible solution for me is Option 2 to store data on local disk.
Now that we have both methods created we need to call them. Let's start with reading the local data. It is super simple to use the readLocalFile method. We pass through the file name and if there is data we will pass that data to our parse method. When the parse method runs and there are no errors, the title and description from our data.
We have create a new variable called urlString , this is just to have things look a bit cleaner when we call loadJson. Next we call our loadJson method.
Inside the closure we switch on the result. The two cases that we have are. If the result is successful, we will pass the data that we get from our loadJson method and pass it to our parse method. If loadJson failed, we will print out the error that it passed to this closure.
Now that all the code is done you can build and run the app. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast what if you could invest in your favorite developer? Who owns this outage? Building intelligent escalation chains for modern SRE.
Featured on Meta.
0コメント