See the attached playground file. I'm trying to parse a small json file and having difficulties with some nested arrays.
Should just be adjusting a couple lines of code.
The error I'm getting is:
Decoding Error: Type Mismatch
Type Mismatch: Context(codingPath: [CodingKeys(stringValue: "message", intValue: nil), CodingKeys(stringValue: "BOM", intValue: nil), CodingKeys(stringValue: "items", intValue: nil)], debugDescription: "Expected to decode Dictionary<String, Any> but found an array instead.", underlyingError: nil)
type: Dictionary<String, Any>
Here is an example of the json.
{"error":{"count":1,"maxLevel":1,"serverVersion":"1.8.23.0","list":[{"msg":"Missing Shaft bar : material: PM00000061","level":"warning","step":"BOM","loadCase":"---"}]},"BOM":{"error":0,"error_msg":"","missing":[],"items":[{"cost":15331.07085,"cost_per_unit":15331.07085,"description":"Pulley","partnumber":"Pulley","quantity":1,"unit":"Each","children":[{"cost":7915.189306,"cost_per_unit":3957.594653,"description":"1973 x 100","partnumber":"EndDisk","quantity":2,"unit":"Each","children":[{"cost":1.05241,"cost_per_unit":1,"description":"Oxy Cutter","partnumber":"PM00000021","quantity":1.05241,"unit":"Hr"},{"cost":3956.542243,"cost_per_unit":1.234,"description":"AS 250( 100 )","partnumber":"PM00000050","quantity":3206.274103,"unit":"Kg"}]},{"cost":4058.44,"cost_per_unit":2029.22,"description":"Bikon 1006 400x495","partnumber":"PM00005045","quantity":2,"unit":"Each","children":[]},{"cost":-1,"cost_per_unit":-1,"description":"","partnumber":"","quantity":-1,"unit":"Each","children":[{"cost":-1,"cost_per_unit":-1,"description":"","partnumber":"","quantity":-1,"unit":"Kg"},{"cost":-1,"cost_per_unit":90,"description":"Fine Machine","partnumber":"PM00000016","quantity":-1,"unit":"Hr"},{"cost":-1,"cost_per_unit":320,"description":"Normalize","partnumber":"PM00000017","quantity":-1,"unit":"Ton"},{"cost":-1,"cost_per_unit":90,"description":"Rough Machine","partnumber":"PM00000015","quantity":-1,"unit":"Hr"},{"cost":-1,"cost_per_unit":90,"description":"Bar Ultrasound","partnumber":"PM00000014","quantity":-1,"unit":"Each"}]},{"cost":3357.441544,"cost_per_unit":3357.441544,"description":"1973 ID x 1506 AS 250( 27 )","partnumber":"Shell","quantity":1,"unit":"Each","children":[{"cost":3054.942085,"cost_per_unit":1.234,"description":"AS 250( 27 )","partnumber":"PM00000050","quantity":2475.641884,"unit":"Kg"},{"cost":53.63938,"cost_per_unit":90,"description":"Plate Roll","partnumber":"PM00000010","quantity":0.595993,"unit":"Hr"},{"cost":27.400031,"cost_per_unit":1.2,"description":"Weld MIG","partnumber":"PM00000019","quantity":22.83336,"unit":"Kg"},{"cost":135.36,"cost_per_unit":90,"description":"Weld Prep","partnumber":"PM00000013","quantity":1.504,"unit":"Hr"},{"cost":86.100047,"cost_per_unit":90,"description":"Weld MIG","partnumber":"PM00000012","quantity":0.956667,"unit":"Hr"}]}]}]}}