0

Have datatable and selecting multiple records across multiple pages and trying to convert all selected records data as JSON data structure. I tried below code and getting JSON data and also two extra fields, could you please help me how to remove "check":true,"checked":true in json data.

 fnGetJsonData(){
    console.log(JSON.stringify(this.persons.filter(f => f.checked)));
 }

output:

[{"id":860,"firstName":"Superman","lastName":"Yoda","dropdown":"yuvi","check":true,"checked":true}]

expected JSON data:

[{"id":860,"firstName":"Superman","lastName":"Yoda","dropdown":"yuvi"]

Demo

1 Answer 1

1

You can use Array.map()

const data = this.persons.filter(f => f.checked);

const mappedData = data.map(d => ({id: d.id, firstName: d.firstName, lastName: d.lastName, dropdown: d.dropdown});

console.log(mappedData);
Sign up to request clarification or add additional context in comments.

3 Comments

Hi @Adil Khalil, Could you please suggest me the below question stackoverflow.com/questions/67549092/…
If this answer was helpful, I will appreciate if you can accept it as an answer.
Yes , done. That's helped me a lot. If possible could you pls help me on stackoverflow.com/questions/67549092/…

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.