I am writing a Swift application that relies in part on a large dictionary of arrays. An excerpt looks like this:
let arithmeticalDict:Dictionary<String, Array <String>> =
[
"1116": [],
"1117": [],
"1118": ["(1+1+1)*8"],
"1128": ["1*(1 + 2)*8","(1 + 2)/(1/8)"]
]
I think it might be more manageable to put this into a JSON resource, a technique I have used before for small, simple dictionaries. This case is larger, 715 entries that take up some 370Kb on disk. However in this case I have run into two problems:
How do I specify in the JSON file that each key in the dictionary corresponds to an array of strings (where the arrays are of irregular length and some may contain nothing)?
How do I extract the JSON file into an appropriate
<String, Array <String>>dictionary when loading it in Swift?