我上过这样的课:
export class LogModel {
..
componentSet: Set<string>;
constructor(componentSet: Set<string>) {
this.componentSet = componentSet;
}
我需要将此类发布到Spring boot app。但是我有JSON反序列化的问题,因为:
我必须使用
这样的转换方法`private toArray(set) {
let array: string[] = [];
for (let i = 0; i < set.length; ++i)
array[i] = set[i];
return array;
}`
答案 0 :(得分:1)
在发送到post方法之前先做这样的事情
const postValue = Array.from(this.componentSet);
(OR)
const setValues = this.componentSet.values();
const postValue = Array.from(setValues);
然后发布postValue