0

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:

  1. User is able to change the values only - Value1 sublevel, Value2 sublevel etc.
  2. User cannot change the nested structure.
  3. 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!

Vikita
  • 261
  • 6
  • 16
  • 1
    This may help https://stackoverflow.com/a/32278428/5621827 – jitender Nov 07 '17 at 10:30
  • Thanks @jitender. Your question helped me realise that the question ins't clear enough...What I'm trying to ensure also is that the user doesn't change the nested structure but is able to change on the values. I'll update my question. – Vikita Nov 07 '17 at 10:49
  • is use of `text area` is mandatory here?you can use input fields – jitender Nov 07 '17 at 10:58
  • I am doing this too. There are two views that are required. I have done the first one with the individual inputs and it works as expected... The second one is the JSON view...I am trying to find out more about the requirement... and whether this is really needed but would like to find out more about the feasibility of this. – Vikita Nov 07 '17 at 11:02

0 Answers0