I'm looking for a way to convert my typescript class with dictionary to a JSON object without the brackets.
this is my class
export class MediaTagRequest {
tags: Map<string, string>;
constructor(tags: Map<string, string>) {
this.tags = tags;
}
}
My instantiation
let tags = new Map<string, string>();
tags.set("city", "Karachi");
let mediatagRequest = new MediaTagRequest(tags);
const headers = { 'content-type': 'application/json'}
const body = JSON.stringify(Object.keys(mediatagRequest.tags.entries()));
My current output:
[["city","Karachi"]]
My desired output:
{
"tags": {
"city": "Karachi"
}
}
Can someone help me please, thank you.