dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.44k stars 4.76k forks source link

Add a property on runtime in json using System.Text.Json #37252

Closed nexawo closed 3 years ago

nexawo commented 4 years ago

Below is JSON I am getting from a database. I have to go through each of the keys in the JSON and check if there is a period (.) in the key name; if so, I need to add a property required with the value of true in the JSON in order to provide runtime validation: e.g Event date and Duration in below json I want to add property ("required":true ) for the EventDate and for Duration i want to add (validation:{"required":true}) because they have period (.) in their key value.

{ "display": "wizard", "settings": {}, "components": [{ "title": "Event Information", "label": "Event Information", "type": "panel", "key": "EventInformation", "components": [{ "label": "Row1Columns", "columns": [{ "components": [{ "label": "Event Date", "format": "dd/MM/yyyy hh:mm a", "tableView": false, "datePicker": { "disableWeekends": false, "disableWeekdays": false }, "validate": { "unique": true }, "key": "Event.EventDate", "type": "datetime", "input": true, "suffix": "<i ref=\"icon\" class=\"fa fa-calendar\" style=\"\">", "widget": { "type": "calendar", "displayInTimezone": "viewer", "language": "en", "useLocaleSettings": false, "allowInput": true, "mode": "single", "enableTime": true, "noCalendar": false, "format": "dd/MM/yyyy hh:mm a", "hourIncrement": 1, "minuteIncrement": 1, "time_24hr": false, "minDate": null, "disableWeekends": false, "disableWeekdays": false, "maxDate": null } }], "width": 6, "offset": 0, "push": 0, "pull": 0 }, { "components": [{ "label": "Duration (minutes)", "mask": false, "spellcheck": true, "tableView": false, "delimiter": false, "requireDecimal": false, "inputFormat": "plain", "key": "Event.Duration", "type": "number", "input": true }], "width": 6, "offset": 0, "push": 0, "pull": 0 }], "tableView": false, "key": "row1Columns", "type": "columns", "input": false }, { "label": "Row2Columns", "columns": [{ "components": [{ "label": "Event Category", "widget": "choicesjs", "tableView": true, "dataSrc": "custom", "data": { "custom": "values = getEventCategoryValues()" }, "valueProperty": "AgencyEventCategoryId", "template": "{{ item.text }}", "selectThreshold": 0.3, "validate": { "required": true }, "key": "Event.AgencyEventCategoryId", "type": "select", "indexeddb": { "filter": {} }, "input": true }], "width": 6, "offset": 0, "push": 0, "pull": 0 }, { "components": [{ "label": "Attendance", "widget": "choicesjs", "tableView": true, "multiple": false, "dataSrc": "custom", "data": { "custom": "values = getAttendanceValues()" }, "valueProperty": "AgencyEventAttendanceId", "template": "{{ item.text }}", "selectThreshold": 0.3, "validate": { "required": true, }, "key": "Event.AgencyEventAttendanceId", "type": "select", "indexeddb": { "filter": {} }, "input": true }], "width": 6, "offset": 0, "push": 0, "pull": 0 }], "tableView": false, "key": "row2Columns", "type": "columns", "input": false }, { "label": "Event Options", "widget": "choicesjs", "tableView": true, "multiple": true, "dataSrc": "custom", "data": { "custom": "values = getEventManagerValues(data.Event.AgencyEventCategoryId)" }, "template": "{{ item.text }}", "refreshOn": "Event.AgencyEventCategoryId", "clearOnRefresh": true, "selectThreshold": 0.3, "calculateServer": false, "validate": { "required": true, "multiple": true }, "key": "Event.EventDetail", "type": "select", "indexeddb": { "filter": {} }, "input": true }, { "label": "Casenote", "wysiwyg": true, "autoExpand": true, "spellcheck": true, "tableView": true, "calculateServer": false, "key": "Event.EventCasenote[0].Casenote", "type": "textarea", "input": true }], "input": false, "tableView": false, "breadcrumbClickable": true, "buttonSettings": { "previous": true, "cancel": true, "next": true }, "collapsible": false }] }

ghost commented 3 years ago

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of the experimental issue cleanup initiative we are currently trialing in a limited number of areas. Please share any feedback you might have in the linked issue.

ghost commented 3 years ago

This issue will now be closed since it had been marked no recent activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.