My attempt to convert a JavaScript object into JSON is not working as expected. When I use console.log(myObject)
, the object is displayed correctly.
However, when I try
console.log(JSON.stringify(myObject));
, I only get an empty object {}
.
Can anyone point out what could be causing this issue? Please see below for the object in question:
Object
autor: "Administrador"
descripcion: "At Google I/O 2015, everything we’ve seen and learned about is under the command of Sundar Pichai. In this exclusive interview, he walks us through his product vision."
titulo: "The future of Google with Sundar Pichai"
url_imagen: "https://i.ytimg.com/vi/TguamcqrQjI/sddefault.jpg"
url_video: "https://www.youtube.com/embed/TguamcqrQjI"
__proto__: Object
For clarification, here is how I am creating the object:
var myObject = {};
$http.get('apiCallToYoutubeIcantShareHereCauseItContainsAPrivateKey')
.success(function(data) {
myObject.titulo = data['items'][0]["snippet"]['title'];
myObject.descripcion = data['items'][0]["snippet"]['description'];
myObject.url_video ="https://www.youtube.com/embed/"+idYoutube;
myObject.url_imagen = data['items'][0]["snippet"]['thumbnails']['standard']["url"];
myObject.autor = 'Administrador';
});