0
0
0348raven2018-04-25 19:44:42
JavaScript
0348raven, 2018-04-25 19:44:42

How to bring form data to a certain form?

I have a specific JSON that I use to build a form:

{
  "0": {
    "property1": {
      "label": "label1",
      "value": ""
    }
    "property2": {
      "label": "label2",
      "value": "",
      "variants": {
        "0": "variant1",
        "1": "variant2"
      }
    },
    "property3": {
      "label": "label3",
      "value": ""
    }
  }
}

Then I get the data using FormData, it comes in a format that doesn't suit me:
{
    "property1": "value1",
    "property2": "variant2",
    "property3": "value3"
}

How can I bring to the desired form, that is, I need the values ​​\u200b\u200bto be set to value. In this case, it is necessary to check the current data, that is, add data to a predefined JSON but with a key one more than the last one.
How it is better to implement it? It is possible that in principle I am doing something wrong and I need it differently, I will be glad for any help, thanks!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question