I am trying to get JSON from an external source, using AlamoFire tools. Using the .responseJSON method works, but that will be deprecated and in any case I know .responseDecodable is more sound. However, I cannot figure out how to model the data so it will decode. Here is the returned JSON:
{
p = 1668147588893;
q = {
cue = (
(
1667442513807,
{
done = 0;
link = new;
share = 0;
tags = new;
title = new;
}
),
(
1667442494796,
{
done = 0;
link = "~.new";
share = 0;
tags = new;
title = new;
}
),
(
1667441502089,
{
done = 1;
link = "~.s";
share = 0;
tags = s;
title = gogogo;
}
)
);
};
}
I am working on the model, but cannot figure out how to deal with the first element of each underlying item having no key value. Otherwise I think this would be trivially easy. I'm sure there must be some way to use init and a custom decoder, but I cannot figure it out. So far I just have:
struct Response: Decodable {
let p: Int
let q: CueFeed
}
struct CueFeed: Decodable {
let cue: [CueItem]
}
But I don't know how to write the struct for CueItem.