0

I have class like:

export class LogModel {
..
componentSet: Set<string>;
constructor(componentSet: Set<string>) {
    this.componentSet = componentSet;
}

And I need to post this class to Spring boot app. But I have the problem with JSON deserialization because: enter image description here

And I have to use transform method like

`private toArray(set) {
        let array: string[] = [];
        for (let i = 0; i < set.length; ++i)
            array[i] = set[i];
        return array;
    }`

in order to have enter image description here How to properly POST this class?

3
  • So you want to convert Set to Array? Is this exactly you want? Commented Mar 18, 2019 at 10:56
  • @ArpitMeena No. I use this method for: componentSet: [] Commented Mar 18, 2019 at 11:00
  • accept the answer if you are satisfied Commented Mar 18, 2019 at 13:54

1 Answer 1

1

Do like this before sending to post method

const postValue = Array.from(this.componentSet);

(OR)

const setValues = this.componentSet.values();
const postValue = Array.from(setValues);

Then post the postValue

Sign up to request clarification or add additional context in comments.

1 Comment

Array.from(this.componentSet) is sufficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.