Quantcast
Channel: Active questions tagged keymapping - Stack Overflow
Viewing all articles
Browse latest Browse all 74

Deep objects key mapping to create single json [closed]

$
0
0

I have set of form questions. Those question are deep inside columns, panels etc. I also have a different objects where I have set of answers with questions keys and value as answers to the questions.

Right now I have to loop through each condition by panel or columns to get question and its key to map with answers key. But its not very effective.

Ans keys.

answers: {"item23": "sdfg","item13": "fg","item6": "asddd","item11": "fg","item18": "ghj","date6": "2024-04-24T12:00:00+05:30","item9": "asdf","item21": "dsfg","item20": "fg","item15": "dfg","item16": "dfgs","item17": "dfg","item8": "sdf","date7": "2024-04-08T12:00:00+05:30","item": "df","item12": "fg","item1": "asd","item7": "df","date1": "2024-04-09T12:00:00+05:30","item19": "hjk","item10": "fgs","item22": "sdfgsdfgsfdg","date4": "2024-04-30T12:00:00+05:30","item14": "fgj","date5": "2024-04-29T12:00:00+05:30"}

questions

{"components": [        {"label": "Panel","components": [                {"tableView": false,"columns": [                        {"width": 4,"offset": 0,"currentWidth": 4,"pull": 0,"components": [                                {"input": true,"type": "textfield","key": "item","tableView": true,"applyMaskOn": "change","label": "ITEM #"                                }                            ],"size": "md","push": 0                        },                        {"pull": 0,"size": "md","currentWidth": 4,"components": [                                {"key": "item1","applyMaskOn": "change","tableView": true,"type": "textfield","input": true,"label": "Compliance Completed By"                                }                            ],"offset": 0,"push": 0,"width": 4                        },                        {"currentWidth": 4,"size": "md","components": [                                {"datePicker": {"disableWeekdays": false,"disableWeekends": false                                    },"enableMinDateInput": false,"label": "Date ","key": "date1","input": true,"widget": {"format": "yyyy-MM-dd hh:mm a","disableWeekends": false,"displayInTimezone": "viewer","disableWeekdays": false,"maxDate": null,"minDate": null,"noCalendar": false,"type": "calendar","mode": "single","useLocaleSettings": false,"allowInput": true,"enableTime": true,"locale": "en","hourIncrement": 1,"time_24hr": false,"minuteIncrement": 1                                    },"enableMaxDateInput": false,"tableView": false,"type": "datetime"                                }                            ],"width": 4                        }                    ],"key": "columns3","input": false,"type": "columns","label": "Columns"                },                {"tableView": true,"label": "Noted Deficiency:","type": "textfield","input": true,"key": "item8","applyMaskOn": "change"                },                {"label": "Course of Action:","applyMaskOn": "change","input": true,"key": "item9","type": "textfield","tableView": true                },                {"key": "columns6","columns": [                        {"size": "md","width": 4,"components": [                                {"applyMaskOn": "change","label": "ITEM #","tableView": true,"type": "textfield","key": "item6","input": true                                }                            ],"currentWidth": 4,"push": 0,"pull": 0,"offset": 0                        },                        {"offset": 0,"width": 4,"push": 0,"currentWidth": 4,"components": [                                {"applyMaskOn": "change","input": true,"type": "textfield","tableView": true,"label": "Compliance Completed By","key": "item7"                                }                            ],"pull": 0,"size": "md"                        },                        {"components": [                                {"datePicker": {"disableWeekdays": false,"disableWeekends": false                                    },"enableMaxDateInput": false,"enableMinDateInput": false,"label": "Date ","widget": {"time_24hr": false,"disableWeekdays": false,"maxDate": null,"hourIncrement": 1,"format": "yyyy-MM-dd hh:mm a","type": "calendar","displayInTimezone": "viewer","minuteIncrement": 1,"disableWeekends": false,"noCalendar": false,"useLocaleSettings": false,"locale": "en","mode": "single","enableTime": true,"allowInput": true,"minDate": null                                    },"tableView": false,"key": "date4","type": "datetime","input": true                                }                            ],"size": "md","currentWidth": 4,"width": 4                        }                    ],"tableView": false,"label": "Columns","input": false,"type": "columns"                },                {"label": "Noted Deficiency:","key": "item13","tableView": true,"applyMaskOn": "change","type": "textfield","input": true                },                {"label": "Course of Action:","input": true,"tableView": true,"applyMaskOn": "change","type": "textfield","key": "item12"                },                {"columns": [                        {"width": 4,"components": [                                {"applyMaskOn": "change","label": "ITEM #","tableView": true,"type": "textfield","key": "item10","input": true                                }                            ],"size": "md","offset": 0,"push": 0,"pull": 0,"currentWidth": 4                        },                        {"offset": 0,"currentWidth": 4,"pull": 0,"width": 4,"components": [                                {"type": "textfield","key": "item11","applyMaskOn": "change","tableView": true,"input": true,"label": "Compliance Completed By"                                }                            ],"size": "md","push": 0                        },                        {"width": 4,"size": "md","components": [                                {"enableMaxDateInput": false,"label": "Date ","widget": {"locale": "en","minDate": null,"mode": "single","type": "calendar","disableWeekends": false,"enableTime": true,"displayInTimezone": "viewer","noCalendar": false,"maxDate": null,"minuteIncrement": 1,"disableWeekdays": false,"time_24hr": false,"format": "yyyy-MM-dd hh:mm a","hourIncrement": 1,"allowInput": true,"useLocaleSettings": false                                    },"enableMinDateInput": false,"input": true,"datePicker": {"disableWeekends": false,"disableWeekdays": false                                    },"tableView": false,"key": "date5","type": "datetime"                                }                            ],"currentWidth": 4                        }                    ],"key": "columns7","input": false,"tableView": false,"type": "columns","label": "Columns"                },                {"label": "Noted Deficiency:","input": true,"type": "textfield","tableView": true,"applyMaskOn": "change","key": "item15"                },                {"key": "item14","label": "Course of Action:","tableView": true,"input": true,"applyMaskOn": "change","type": "textfield"                },                {"type": "columns","columns": [                        {"components": [                                {"key": "item18","label": "ITEM #","input": true,"applyMaskOn": "change","tableView": true,"type": "textfield"                                }                            ],"size": "md","width": 4,"pull": 0,"push": 0,"currentWidth": 4,"offset": 0                        },                        {"offset": 0,"width": 4,"components": [                                {"applyMaskOn": "change","key": "item19","input": true,"label": "Compliance Completed By","type": "textfield","tableView": true                                }                            ],"currentWidth": 4,"push": 0,"size": "md","pull": 0                        },                        {"size": "md","currentWidth": 4,"width": 4,"components": [                                {"datePicker": {"disableWeekdays": false,"disableWeekends": false                                    },"enableMaxDateInput": false,"widget": {"noCalendar": false,"minDate": null,"locale": "en","time_24hr": false,"displayInTimezone": "viewer","mode": "single","disableWeekends": false,"allowInput": true,"useLocaleSettings": false,"hourIncrement": 1,"type": "calendar","minuteIncrement": 1,"format": "yyyy-MM-dd hh:mm a","enableTime": true,"disableWeekdays": false,"maxDate": null                                    },"label": "Date ","type": "datetime","input": true,"enableMinDateInput": false,"tableView": false,"key": "date7"                                }                            ]                        }                    ],"key": "columns9","tableView": false,"label": "Columns","input": false                },                {"applyMaskOn": "change","input": true,"label": "Noted Deficiency:","key": "item20","type": "textfield","tableView": true                },                {"type": "textfield","applyMaskOn": "change","label": "Course of Action:","key": "item21","tableView": true,"input": true                },                {"tableView": false,"input": false,"columns": [                        {"offset": 0,"components": [                                {"key": "item16","input": true,"label": "ITEM #","tableView": true,"applyMaskOn": "change","type": "textfield"                                }                            ],"size": "md","push": 0,"currentWidth": 4,"pull": 0,"width": 4                        },                        {"width": 4,"push": 0,"offset": 0,"size": "md","currentWidth": 4,"pull": 0,"components": [                                {"tableView": true,"key": "item17","label": "Compliance Completed By","applyMaskOn": "change","type": "textfield","input": true                                }                            ]                        },                        {"currentWidth": 4,"size": "md","components": [                                {"input": true,"widget": {"noCalendar": false,"hourIncrement": 1,"disableWeekdays": false,"minDate": null,"enableTime": true,"displayInTimezone": "viewer","format": "yyyy-MM-dd hh:mm a","minuteIncrement": 1,"allowInput": true,"mode": "single","time_24hr": false,"useLocaleSettings": false,"disableWeekends": false,"type": "calendar","locale": "en","maxDate": null                                    },"label": "Date ","enableMinDateInput": false,"datePicker": {"disableWeekdays": false,"disableWeekends": false                                    },"key": "date6","tableView": false,"enableMaxDateInput": false,"type": "datetime"                                }                            ],"width": 4                        }                    ],"type": "columns","key": "columns8","label": "Columns"                },                {"type": "textfield","tableView": true,"key": "item23","label": "Noted Deficiency:","applyMaskOn": "change","input": true                },                {"tableView": true,"applyMaskOn": "change","input": true,"key": "item22","type": "textfield","label": "Course of Action:"                }            ],"input": false,"type": "panel","tableView": false,"key": "directorDeficiencyComplianceReport","collapsible": false,"title": " DIRECTOR DEFICIENCY COMPLIANCE REPORT"        },        {"input": true,"disableOnInvalid": true,"tableView": false,"label": "Submit","type": "button","key": "submit"        }    ],"display": "form"}

Those item1, item2, item and its inner properteis are the key to the question where they are places in deep objects. Is there any way I can map them with the help any library such as loadsh ?

sample of my object of answers and question in below screenshot

this is how the form looks with answers. But I need both question ans answer in one single object.Right now with this form I need to pass question and answers in different properties.enter image description here


Viewing all articles
Browse latest Browse all 74

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>