I am seeking a solution to convert my typescript class with a dictionary into a JSON object format without the brackets.
Here is my class:
export class MediaTagRequest {
tags: Map<string, string>;
constructor(tags: Map<string, string>) {
this.tags = tags;
}
}
This is how I instantiate it:
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()));
Current output:
[["city","Karachi"]]
Desired output:
{
"tags": {
"city": "Karachi"
}
}
If anyone could assist me with this issue, I would greatly appreciate it. Thank you.