I have the following case: need to display a big JSON object in the front-end within a textarea. User should be able to update the values in the textarea and then save.
I have the following format:
{
"Key1 rootLevel": {
"Key1 subLevel": "Value1 sublevel",
"Key2 subLevel": "Value2 sublevel",
"Key3 subLevel": "Value3 sublevel",
},
"Key2 rootLevel": {
"Key1 subLevel": "Value1 sublevel",
"Key2 subLevel": "Value2 sublevel",
"Key3 subLevel": "Value3 sublevel",
},
"Key3 rootLevel": {
"Key1 subLevel": "Value1 sublevel",
"Key2 subLevel": "Value2 sublevel",
"Key3 subLevel": "Value3 sublevel",
},
}
Value1, Value2, Value3 rootLevel are nexted objects. The whole Json has about 270 entries...
What is the best way to achieve the following:
- User is able to change the values only - Value1 sublevel, Value2 sublevel etc.
- User cannot change the nested structure.
- Validate the JSON value in the textarea on the front-end before saving?
OR
Just do the validation server-side and just send the data?
Thank you!