find the last modified date of a json file in swift

You can use the FileManager class to get the attributes of the file and then extract its modification date as follows:

main.swift
let filePath = "path/to/your/file.json"

do {
   let attributes = try FileManager.default.attributesOfItem(atPath: filePath)
   let modificationDate = attributes[.modificationDate] as? Date
   print("File modification date: ", modificationDate)
} catch {
   print("Error: ", error.localizedDescription)
}
305 chars
10 lines

This code will print the last modification date of the JSON file. Make sure to replace path/to/your/file.json with the actual path to your JSON file.

gistlibby LogSnag