I'm doing a dynamic form where I get a Json
and I create a dynamic form, it's all automated, except the part that I have to extract every string
from the JSon
and put inside a array
.
I'm doing a dynamic form where I get a Json
and I create a dynamic form, it's all automated, except the part that I have to extract every string
from the JSon
and put inside a array
.
Think like this:
This is an object: { }
, and this is an array: []
Every "JSON" output is considered an object. Even the array in JavaScript is seen with an Array-only object.
In case, when you receive a collection in "JSON" with keys and assigns a name to these keys: var obj = { nome: "x", id: "y" }
The correct way to access your "x" and "y" values is by calling the object obj: .name, obj.id. The same can be done in another way, as done in the array, however this is valid in cases where the keys will be dynamic: obj["nome"]; obj["id"];
Now think that if you want to receive a JSON as a string, it's the same as ignoring all these rules. Then you just get the whole object, and convert it to a string, so use the method JSON.stringify(obj)
;