I have a class in Typescript containing a map:
public map:Map<string,string>;
constructor() {
let jsonString = {
"peureo" : "dsdlsdksd"
};
this.map = jsonString;
}
Problem is that the initialization doesn't work.
jsonString is something that I will receive from a Java Object serialized to Json.
Anyone can help? Thanks!
You must iterate over the members of the object and add it to the map:
public map: Map<string, string> = new Map<string, string>();
constructor() {
let jsonString = {
"peureo": "dsdlsdksd"
};
for (let member in jsonString) {
this.map.set(member, jsonString[member]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With