I am new to json and javascript but I have some experience with Java. I wanted to know how to create an array of objects but not sure how to design. What I want to do is to be able to call
object1.field1
where object1
is stored in an array like
array = [object1, object2, object3...];
and inside object1 would look like
object1:
field1: value1,
field2: value2,
So my question is how would I create the array to hold these values so I can use it for testing? I was thinking either two possible design:
array: [
object1:{
field1: value1,
field2: value2},
object2: {
field1: value1,
field2: value2}]
or
array: {
object1:[
field1: value1,
field2: value2],
object2: [
field1: value1,
field2: value2]}
I was thinking the first one would be correct because it wouldn't be possible to call object1.field1
if the fields were stored in an array.