cph-cachet / research.package

A Flutter package implementing support for surveys like ResearchStack and ResearchKit
MIT License
50 stars 43 forks source link

RPTaskResult does not deserialize RPStepResult in results #83

Open jeyjey626 opened 1 year ago

jeyjey626 commented 1 year ago

When deserializing RPTaskResult, all results in results map are deserialized as RPResult, not RPStepResult, resulting in loss of information.

https://github.com/cph-cachet/research.package/blob/c9ae9595b4dbab36f441b1db4de753a3da2a22c9/lib/src/model/result/RPTaskResult.dart#L32

bardram commented 1 year ago

Hi @jeyjey626 - I've looked into this.

The reason why this happens is because the different result objects have never been designed to be de-serialized from JSON into Dart objects. Normally, you would take the Dart result object and serialize it to JSON (using the toJson function) and save it to a file or database.

We never thought that you would need to read this JSON again and de-serialize it back to the app.

So - if I'm to change this, I need to know why you are doing this. What is the use case?