Within the app main struct, the SwiftData modelContainer is created by fetching and decoding JSON from remote site. The decoded data is inserted into the modelContext. Immediately thereafter, the app crashes with the error Could not cast value of type '__NSCFBoolean' to 'NSString' . I have run the JSON from the site through JSON lint and it is correctly structured.
The JSON data is structured as follows: Overview object which includes a Result object which includes a List Array. Each List object includes a Books Array.
I have run the app through AI and the result indicates that there is data corruption when adding the data to the database. The AI rewrote the code such that the book data is encoded into a data blob and then adds the data to the database, instead of adding the individual books (which is extensive.) This approach works without crashing, but I would like to find out if this is indeed a SwiftData issue.