Very generic Typescript question:
I use an API that returns all kind of JSON payloads. Most are just objects, some also arrays/lists of objects. Now I could of course just work with these in my Ionic app, but I assume that would be almost as bad as defining everything as
any and then just throw in what I get (I read my share of @rapropos messages here in the forum)… I sure have my problems with giving methods the wrong data because it is a similar Type, but not the same. Having it done right should help here.
What is the best way to get the JSON data I retrieve from the API into proper typed Classes/Objects?
The API is not the cleanest one. Many result lists are not a “Array of Foo” but “Array of generic object and a property
foo with Foo in it, and some random other properties (of the category
action_done_at)”. How to handle this?
(PS: Please excuse my Programming 101 ignorance of Class, Object, Type, … But feel free to correct me.)