Java Map to JSON to Typescript Map : <p>on my server side I have a Java object that contains a HashMap. I want to serialize it to JSON, return it to my Angular2 client and use it as a Map/Dictionary there. </p>

<p>Here's the class:</p>

<pre><code>public class FileUploadResult {
    String timestamp;
    String message;
    String status;
    HashMap&lt;String, String&gt; parameters;

    public FileUploadResult(String status, String message, String timestamp, HashMap parameters) {
        this.status = status;
        this.message = message;
        this.timestamp = timestamp;
        this.parameters = parameters;
    }
</code></pre>

<p>}</p>

<p>Here's the JSON that I receive on the client side:</p>

<pre><code>{"timestamp":"","message":"Test","status":"1","parameters":{"myKey":"Value","mySecondKey":"Another Value"}}
</code></pre>

<p>Here's my receiving Angular2 http call:</p>

<pre><code>this.http.post(this.uploadURL, formData).map((res:Response) =&gt; res.json() as FileUploadResult).catch(this.handleError); 
</code></pre>

<p>FileUploadResult on the client looks like this:</p>

<pre><code>export class FileUploadResult {
    status: string;
    timestamp: string;
    message: string;
    parameters: Map&lt;string, string&gt;;

    constructor() {
        this.parameters = new Map&lt;string, string&gt;();
    }

    addParameter(key: string, value: string) {
        this.parameters.set(key, value);
    }

    getParameters() {
        return this.parameters;
    }
}
</code></pre>

<p>By using the "as FileUploadResult" in the http.map call, I expected to get an object on where I can call <code>result.getParameters().get("myKey")</code>. But that's not happening. I get an unspecified object where the only call that works is <code>result.parameters.myKey</code>. Is there a way to achieve what I want and to cast the JSON object to the FileUploadResult including the Angular2 map?</p>
