cancel
Showing results for 
Search instead for 
Did you mean: 

Encode and Decode EntityValueList

0 Kudos

I am trying to JSON encode and decode an EntityValueList that is the result of executing a query (QueryResult.entityList).

let encodedData = try JSONEncoder().encode(list)   // Works!
let JSONString = String(data: encodedData, encoding: .utf8)   // Works!            
print(JSONString)   // Works! - prints out the objects
let decoder = JSONDecoder()          
decoder.userInfo[CSDLDocument.csdlInfoKey] = MyAppMetadata.document            
let equipmentList = try decoder.decode(EntityValueList.self, from: encodedData)   // Fails!

The error is that @entityType' key is missing but I can verify, using the above JSONString, that each

object in the JSON is the right entityType and that it has an '@EntityType' property.

Are there hidden properties or similar that are omitted when encoding or decoding - or even better, is there a different approach to create EntitValues from a JSON file?

  • SAP Managed Tags:

Accepted Solutions (0)

Answers (0)