DEV Community

loading...

filter object from an array

pravenpatel profile image praveen patel ・1 min read

I have json data like this.

 Object
date1: {enabled: false, label: "Date1 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 20}
date2: {enabled: false, label: "Date2 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 21}
date3: {enabled: false, label: "Date3 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 22}
date4: {enabled: false, label: "Date4 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 23}
date5: {enabled: false, label: "Date5 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 24}
dropdown1: {enabled: true, label: "Country", eformVisible: false, mandatory: "NOT_MANDATORY", order: 30, …}
dropdown2: {enabled: false, label: "Dropdown2 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 31, …}
dropdown3: {enabled: false, label: "Dropdown3 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 32, …}
dropdown4: {enabled: false, label: "Dropdown4 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 33, …}
dropdown5: {enabled: false, label: "Dropdown5 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 34, …}
email1: {enabled: false, label: "Email1 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 25}
email2: {enabled: false, label: "Email2 Label", eformVisible: false, mandatory: "NOT_MANDATORY", order: 26}
Enter fullscreen mode Exit fullscreen mode

from this json data i need to get only value of enabled:true. based on this value textbox or dropdown should enabled.
first i tried to separate an arrya based on the ebaled:true value but not getting exact solution.because
formate is object[][] show its not giving exactly what i want.
provide solution how to get object only enabled true using typescript or html

Discussion (0)

pic
Editor guide