CB not creating the outer init correctly.
Firstly NIX for a great App, awesome isn't a word I use that often being a lot older than you but a very impressive piece of work, many thanks.
Attached is some very typical NASA JSON from their public interfaces. It's actually relatively simple and well behaved compared to what you can request :-)
I am taking this and then running it through CuteBaby to generate the structure off the JSON.
Towards the bottom of the output CB has two errors:-
-
- Unsupported; array in array!
- init?(json: [String: Any]) {
I think 2. is meant to be the init for NewModel.
I am Decodable(ing) all the structs and everything else is fine although the array is being handled piecemeal.
Could I have your thoughts?
Many thanks,
Ed Hasted
Hi - I have run this with the Codable option ticked (doh) but it still doesn't create the Init for NewModel so you still get a "Type 'NewModel' does not conform to protocol 'Decodable'" error.
Also has two further errors lower down:
let messages: [Any] //TODO: Specify the type to conforms Decodable protocol let time: [Any] //TODO: Specify the type to conforms Decodable protocol
If you // them out the process appears to work and compiles.
Think there is some minor modification to the code required - fantastic work.
@EdHasted The NASAJSON has some parts that Baby can not handle.
- The
ALLSKY_SFC_SW_DWNis a dictionary, but maybe have different keys for different response. - The
messagesis a array, but with no items in it. - The
timeis a array with sub array as it's item (which item's type is String or Double)
I'm sorry that Baby is not strong enough to infer this JSON.
Many thanks - still think it's an excellent App. Can you recommend any products that might be able to generate the Swift code as I need a solution fast? Again many thanks.