我想创建一个 json 对象,例如:
{
name: "Julia"
birthdate: "xxxx"
movies: [{title: "movie1", rating: 5}, {title: "movie2", rating 3}}]
}
我想做类似的事情:
var myobj = [];
myobj.push({name: "Julia", birthdate: "xxxx"});
myobj.movies = [];
myobj.movies.push({title: "movie1", rating: 5});
myobj.movies.push({title: "movie2", rating: 3});
但我无法创建那个“电影”部分。我该如何做到这一点?