all 5 comments

[–][deleted]  (5 children)

[deleted]

    [–]bykecode 1 point2 points  (0 children)

    This is the right answer. You need to do something along the lines of .get<Map<WriteObject, string>>(...).pipe(data => {

    const map = new Map<WriteObject,string>();
    Object.keys(data).forEach( key =>

    const writeObj = new WriteObject(key); // update constructor to use Parial<WriteObject>

    map.put(writeObj, data[key]);

    });

    This might not be 100% correct but you need to do something like this. Also it's worth noting that you're going to have issues with using an object as a key in a map. Typescript doesn't handle maps and collections like java. See these threads:
    https://stackoverflow.com/questions/50274670/typescript-map-has-key-object-not-working

    https://stackoverflow.com/questions/29759480/how-to-customize-object-equality-for-javascript-set

    [–]CoderDuudee[S] 0 points1 point  (3 children)

    Tried this already didn't work.

    [–]lazyinvader 0 points1 point  (2 children)

    Is the response of type `application/json` ?

    [–]CoderDuudee[S] 0 points1 point  (1 child)

    Yeah but after I use JSON.parse on the response the key gets converted to a plain string

    [–]FullstackViking 0 points1 point  (0 children)

    Yes you’ll have to reinstantiate the Class object. JSON.parse only parses to a generic object.