You can find the extension of a JSON file in Swift by using the pathExtension
property of URL
. Here's an example:
main.swift198 chars9 lines
In this example, replace "/path/to/file.json" with the path to your JSON file. The pathExtension
property returns the extension of the file, which is then compared to "json" to determine if it's a JSON file.
gistlibby LogSnag