Try with these as your Codable structs:
struct Synapses: Codable {
var synapses: [SynapsData]
}
struct SynapsData: Codable {
var id : Int
var xPosition : CGFloat
var yPosition : CGFloat
var width : CGFloat
var height : CGFloat
}
and this as your JSON file:
{
"synapses": [
{
"id": 0,
"xPosition": 387.8125,
"yPosition": 502.96875,
"width": 187.375,
"height": 122.0625
},
{
"id": 16,
"xPosition": 490.859375,
"yPosition": 947.15625,
"width": 49.28125,
"height": 69.6875
}
]
}
then decode Synapses.self from the data of your JSON file
Topic:
App & System Services
SubTopic:
General
Tags: