JSON File Question

I'm very new to JSON and parsing jason. I have watched some tutorials and it seems like Swift 4 makes JSON parsing quite easy. I am currently working on a project in which we want to build a task tracker. The idea is that we will have a task list (UITableView) with things such as name, owner, status etc.


My question is: Can a JSON file be "live file" i.e. if new tasks are added, they would automatically get populated in the JSON and those new tasks would appear in the tableview?


Also if anyone has any resources that they can point to about learning JSON that would be great!

Accepted Reply

My question is: Can a JSON file be "live file" i.e. if new tasks are added, they would automatically get populated in the JSON and those new tasks would appear in the tableview?

Possibly, but that’s probably the wrong way to approach this. Observing a file on disk directly is possibly but it’s not easy. Instead most folks handle this way of model objects. Changing these model objects then triggers two types of action:

  • Writing the model to disk

  • Updating the views to display the new model

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

This doesn't appear to be a question about a feature of the Swift language, so it's posted in the wrong forum. Getting Started might be better.


Why are you planning on using JSON? Normally, it's an implementation detail of the API contract between a client and server. Is there a server involved when "new tasks are added"?

My question is: Can a JSON file be "live file" i.e. if new tasks are added, they would automatically get populated in the JSON and those new tasks would appear in the tableview?

Possibly, but that’s probably the wrong way to approach this. Observing a file on disk directly is possibly but it’s not easy. Instead most folks handle this way of model objects. Changing these model objects then triggers two types of action:

  • Writing the model to disk

  • Updating the views to display the new model

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"