I am a beginner and am trying to create the following JSON From data extraction of HTML input texts. How can I create and access the following JSON?
{
Brazilians**{
John**{
old: 18
}
Jones**{
old: 20
}
}
Canadians**{
Friedman**{
old: 22
}
James**{
old: 35
}
}
}
Note: ** Means it must be a dynamic key.
My HTML code:
<input type="text" id="nacionality">
<input type="text" id="name">
<input type="text" id="old">
The structure I tried to develop in javascript:
obj[nationality] = name[{old : oldValue}];
alert(obj["Brazilians"]["John"].old);