I have a JSON object that I need to get a price from.
This is the object reference that works ... I want to get the data.
dataJSON.companies [0] .fields.Internet.lengthWhat do I need to do to somehow evaluate the object with a string variable . Something like this ...
var mediaType = 'Internet'; DataJSON.companies [0] .fields + MediaType + .length;
Is there any way to do this? I've been stumped.
When you do not know the name of the property till runtime.
var mediaType = 'Internet'; DataJSON.companies [0] .field [media type]. Length;
You can access the members of the object either with dot notation or square bracket notation.
For example
var results = myobject.propertname;
or
var results = myobject ["propertyname"];
No comments:
Post a Comment