Baby icon indicating copy to clipboard operation
Baby copied to clipboard

CB not creating the outer init correctly.

Open EdHasted opened this issue 7 years ago • 4 comments

NASAJSON.txt

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!
  1. 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


EdHasted avatar Sep 25 '18 15:09 EdHasted

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.

EdHasted avatar Sep 25 '18 16:09 EdHasted

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 avatar Sep 25 '18 16:09 EdHasted

@EdHasted The NASAJSON has some parts that Baby can not handle.

  1. The ALLSKY_SFC_SW_DWN is a dictionary, but maybe have different keys for different response.
  2. The messages is a array, but with no items in it.
  3. The time is 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.

nixzhu avatar Sep 26 '18 09:09 nixzhu

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.

EdHasted avatar Sep 29 '18 10:09 EdHasted