After retrieving a JSON object from Mongo DB, I have this data structure.
**JSON**
{
"_id" : ObjectId("5265347d144bed4968a9629c"),
"name" : "ttt",
"features" : {
"t" : {
"visual_feature" : "t",
"type_feature" : "Numeric",
"description_feature" : "Time"
},
"y" : {
"visual_feature" : "y",
"type_feature" : "Nominal",
"description_feature" : "Values to be mapped to the y-axis"
},
"x" : {
"visual_feature" : "x",
"type_feature" : "Numeric",
"description_feature" : "Values to be mapped to the x-axis"
}
}
}
My goal is to extract and utilize the values of the "features" attributes within the JSON object for table creation. How can I access these nested attributes (sub JSON object) in Javascript? Specifically, I need to retrieve values from "visual_feature", "type_feature", and "description_feature". UPD I have managed to find a solution.
$.ajax({
url: VASERVER_API_LOC + '/visualization/' + visid + '/',
type: 'GET',
contentType: "application/json",
data: tmp_object,
success: function(json) {
var result = [];
var keys = Object.keys(json);
keys.forEach(function (key){
result.push(json[key]);
});
for(var i=0; i<result.length; i++){
console.log(">>> visual_feature == " + result[i].visual_feature);
console.log(">>> type_feature == " + result[i].type_feature);
console.log(">>> discription_feature == " + result[i].description_feature);
};
}
});
Thank you!!!