I have an xml file that has been converted to the json listed below. I have been trying to figure out how to retrieve -Name and -Value from each of the Attributes with no luck. I'm guessing I need to create a sub-object that is equal to jsonobj.Media.Attribute[i], but am unable to access -Name or -Value once I do that. Any suggestions?
jsonobj= {
"Media": {
"Attribute": [
{
"-Name": "Keywords",
"-Value": "keyword value"
},
{
"-Name": "Title",
"-Value": "title value"
},
{
"-Name": "Description",
"-Value": "description value"
},
{
"-Name": "Author",
"-Value": "author value"
},
{
"-Name": "Copyright",
"-Value": "copyright value"
}
]
}
};
['-Name']to access elements of the object.-is an operator. If you execute the code, you get an error. Change it to subobject[0].["-Name"] will fix the problem.