OK, so I'm facing this challenge...
Here's how javascript console (in Chrome) prints my object :
And here's what I'd like to do :
var items = [
{
text: "http://www.imdb.com/title/tt0106307/",
children: [
{ text: "Director", children: [ { text: "Emir Kusturica" } ] },
{ text: "Title", children: [ { text: "Arizona Dream" } ] }
]
},
{
text: "http://www.imdb.com/title/tt0110074/",
children: [
{ text: "Director", children: [ { text: "Joel Coen" }, { text: "Ethan Coen"} ] },
{ text: "Title", children: [ { text:"The Hudsucker Proxy" } ] }
]
}
// and so on..
];
How can I do that? Any ideas/pointers to help me get there?
It should definitely be rather simple, but Javascript is definitely not my thing at all...
P.S. This whole object thing is created after a $.parseJSON(myJson)
command - now, don't ask me why it's not converted to a simple nested array and it turns into an object instead... I wish I knew... (not that it'd have the desired structure, but at least it would make more sense)
UPDATE:
OK, and - in case it is helpful - here's my original Json :
{
"http:\/\/www.imdb.com\/title\/tt0106307\/": {
"Title": "Arizona Dream",
"Year": null,
"Director": "Emir Kusturica"
},
"http:\/\/www.imdb.com\/title\/tt0112883\/?ref_=tt_rec_tt": {
"Title": "Don Juan de Marco",
"Year": null,
"Director": "Jeremy Leven"
},
"http:\/\/www.imdb.com\/title\/tt0106387\/?ref_=tt_rec_tt": {
"Title": "Benny & Joon",
"Year": null,
"Director": "Jeremiah S. Chechik"
},
"http:\/\/www.imdb.com\/title\/tt0099487\/?ref_=tt_rec_tt": {
"Title": "\u039f \u03a8\u03b1\u03bb\u03b9\u03b4\u03bf\u03c7\u03ad\u03c1\u03b7\u03c2",
"Year": null,
"Director": "Tim Burton"
},
"http:\/\/www.imdb.com\/title\/tt0354899\/?ref_=tt_rec_tt": {
"Title": "La science des r\u00eaves",
"Year": null,
"Director": "Michel Gondry"
},
"http:\/\/www.imdb.com\/title\/tt0110074\/?ref_=tt_rec_tt": {
"Title": "The Hudsucker Proxy",
"Year": null,
"Director": [
"Joel Coen",
"Ethan Coen"
]
}
}
P.S. (2) What I'm actually trying to do is to simply represent a Json object as a tree using jsTree, and pushing myself to achieve its desired structure.