中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
Map转JSON
微信扫码分享
mapToString(map: Map<string, string | object>): string { if (map.size === 0) { return ''; } let obj: object = new Object; map.forEach((value, key) => { obj[key] = value; }) return JSON.stringify(obj); } //map类型的字符串转map let strParam = '{"main":"aasadada","ks":"sadadas","sc":11111,"update":"asdasdasda"}'; let obj: object = JSON.parse(strParam); let targetMap: Map<string, string | number> = new Map<string, string | number>(Object.entries(obj));