0
I wanted to know how to create a json by taking data from another json using a for
var imdb = {
"title": "Justice League",
"content_rating": "PG-13",
"original_title": "",
"metadata": {
"languages": [
"English"
],
"asp_retio": "1.85 : 1",
"filming_locations": [
"Leavesden Studios",
"Leavesden",
"Hertfordshire",
"England",
"UK"
],
"also_known_as": [
"Justice League"
],
"countries": [
"USA"
],
"gross": "",
"sound_mix": [
"Dolby Digital EX",
"12-Track Digital Sound",
"Dolby Atmos",
"DTS(DTS: X)",
"IMAX 6-Track",
"Sonics-DDP",
"Auro 11.1"
],
"budget": "$300,000,000 (estimated)"
},
"release_date": "2017-11-17",
"director": "Zack Snyder",
"url": {
"url": "http://www.imdb.com/title/tt0974015"
},
"year": "2017",
"trailer": [
{
"mimeType": "video/mp4",
"definition": "480p",
"videoUrl": "https://video-http.media-imdb.com/MV5BODgxMGNmZGMtZDRlNS00NmY5LWFhMWEtOTYyY2M1ZGRiNWNhXkExMV5BbXA0XkFpbWRiLWV0cy10cmFuc2NvZGU@.mp4?Expires=1510767701&Signature=C1mwUKXcw-15NSv59mT1x80KKDaH6y3Kqr0-CYukkYD3kMMIjgZD5-CGkvNCIvVVwHrVxKFvylzPyXIKXhunaeX9wTToX63L0HCmeGQkZ2k5MfTcCuH~drSEHvjfkzIjwjaB6IqJl6N8HAxKse6HRVshm9GcH1uzlHGgoX~Qfns_&Key-Pair-Id=APKAILW5I44IHKUN2DYA"
},
{
"mimeType": "video/mp4",
"definition": "SD",
"videoUrl": "https://video-http.media-imdb.com/MV5BOTQyZTM3ZWQtZGFkYS00ZmVhLWE3YTQtNDU1OWUyNDI2MjkzXkExMV5BbXA0XkFpbWRiLWV0cy10cmFuc2NvZGU@.mp4?Expires=1510767701&Signature=kVjQra9dODbBQ1dDQmocxyanoazz8FxA50M8dVWAfBJk4DxkDW4rdwyDel3oUWGKyvWVmbTLfYfuXKoFLb~MPT~p6CUpTG1g6vE8h2izkRmnHvuiU8kOWHutpjhL88HjtcKCkJYnKy4ebXvKNOYhs2Lsx7qQLoMYhPFNw7FK-iQ_&Key-Pair-Id=APKAILW5I44IHKUN2DYA"
},
{
"mimeType": "application/x-mpegURL",
"definition": "auto",
"videoUrl": "https://imdb-video.media-imdb.com/vi2454436121/hls-1509753918405-master.m3u8?Expires=1510767701&Signature=GfwQhkIRwiBFfcdmK6pf6k8fZUJyi0C44b2m9iEgQWi1qu1io4KolFxH67EIL1DrfgYuASozJx8VI-bjHTcSAzcSD9QCtrwOjbwcPIm8TPlJ1HpbS8GARnr-iynTVm5pLumOz~6KreC3Cj3ziws5rlqC-dBzZVYsSyexwSALq6FNx0FhaIEjAdprby-TSrPPnUAA3NYg1eAvPuwTzTYZZJG6-HwL8x5iPidaiDhlHnfJtnNjYanHqL78zYXMhnP4T2C2LEpoTW~yFXzcYD--a1TNS-92EQU~KBN9m5MRZf4yYp8UVnOnsIgz3GihQy1e1tqJ7oSui9Q8uLuYz3BI3Q__&Key-Pair-Id=APKAIFLZBVQZ24NQH3KA"
}
],
"length": "121",
"cast": [
{
"character": "Diana Prince / Wonder Woman",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjUzZTJmZDItODRjYS00ZGRhLTg2NWQtOGE0YjJhNWVlMjNjXkEyXkFqcGdeQXVyMTg4NDI0NDM@._V1_UY44_CR6,0,32,44_AL_.jpg",
"link": "http://www.imdb.com/name/nm2933757/?ref_=tt_cl_t1",
"name": "Gal Gadot"
},
{
"character": "Antiope",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTU0NTc4MzEyOV5BMl5BanBnXkFtZTcwODY0ODkzMQ@@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm0000705/?ref_=tt_cl_t2",
"name": "Robin Wright"
},
{
"character": "Arthur Curry / Aquaman",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTI5MTU5NjM1MV5BMl5BanBnXkFtZTcwODc4MDk0Mw@@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm0597388/?ref_=tt_cl_t3",
"name": "Jason Momoa"
},
{
"character": "Queen Hippolyta",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTAwOTQ5NTc3OTVeQTJeQWpwZ15BbWU4MDY4MDc1MDYx._V1_UY44_CR1,0,32,44_AL_.jpg",
"link": "http://www.imdb.com/name/nm0001567/?ref_=tt_cl_t4",
"name": "Connie Nielsen"
},
{
"character": "Lois Lane",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjE4NjExMjI1OF5BMl5BanBnXkFtZTcwODc0MjY2OQ@@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm0010736/?ref_=tt_cl_t5",
"name": "Amy Adams"
},
{
"character": "Bruce Wayne / Batman",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTI4MzIxMTk0Nl5BMl5BanBnXkFtZTcwOTU5NjA0Mg@@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm0000255/?ref_=tt_cl_t6",
"name": "Ben Affleck"
},
{
"character": "Barry Allen / The Flash",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjEwMjQ3ODgxOV5BMl5BanBnXkFtZTgwNzc4NjE4NTE@._V1_UY44_CR17,0,32,44_AL_.jpg",
"link": "http://www.imdb.com/name/nm3009232/?ref_=tt_cl_t7",
"name": "Ezra Miller"
},
{
"character": "Mera",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTQ0MjA1ODU0MV5BMl5BanBnXkFtZTgwNTczNTkwNjE@._V1_UY44_CR0,0,32,44_AL_.jpg",
"link": "http://www.imdb.com/name/nm1720028/?ref_=tt_cl_t8",
"name": "Amber Heard"
},
{
"character": "Clark Kent / Superman",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTUxNTExMzUzOF5BMl5BanBnXkFtZTgwOTI1MjA3OTE@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm0147147/?ref_=tt_cl_t9",
"name": "Henry Cavill"
},
{
"character": "Martha Kent",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjE4ODQ5NTgxNl5BMl5BanBnXkFtZTcwNDkwMDgyMg@@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm0000178/?ref_=tt_cl_t10",
"name": "Diane Lane"
},
{
"character": "Iris West",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BNmRhNDM5YzMtMmU4Zi00Y2E2LWIzYzMtN2QwMmY3MTdmYTlhXkEyXkFqcGdeQXVyMzU0NDUwNTc@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm4169922/?ref_=tt_cl_t11",
"name": "Kiersey Clemons"
},
{
"character": "Henry Allen",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTQ5MzM5NzUzMF5BMl5BanBnXkFtZTcwNjEyMDY5Mg@@._V1_UY44_CR0,0,32,44_AL_.jpg",
"link": "http://www.imdb.com/name/nm0001082/?ref_=tt_cl_t12",
"name": "Billy Crudup"
},
{
"character": "Commissioner Gordon",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMzg2NTI5NzQ1MV5BMl5BanBnXkFtZTgwNjI1NDEwMDI@._V1_UY44_CR2,0,32,44_AL_.jpg",
"link": "http://www.imdb.com/name/nm0799777/?ref_=tt_cl_t13",
"name": "J.K. Simmons"
},
{
"character": "Steppenwolf",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTIyNjM0MzU0NF5BMl5BanBnXkFtZTcwOTIxMzg1MQ@@._UY317_CR16,0,214,317_AL_.jpg",
"link": "http://www.imdb.com/name/nm0001354/?ref_=tt_cl_t14",
"name": "Ciar\u00e1n Hinds"
},
{
"character": "Alfred Pennyworth",
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTY5Mzg2NDY5OV5BMl5BanBnXkFtZTcwMDQwNzA0Mg@@._V1_UY44_CR0,0,32,44_AL_.jpg",
"link": "http://www.imdb.com/name/nm0000460/?ref_=tt_cl_t15",
"name": "Jeremy Irons"
}
],
"imdb_id": "tt0974015",
"rating": "8.6",
"genre": [
"Action",
"Adventure",
"Fantasy"
],
"rating_count": "4,322",
"storyline": "Fueled by his restored faith in humanity and inspired by Superman's selfless act, Bruce Wayne enlists the help of his newfound ally, Diana Prince, to face an even greater enemy. Together, Batman and Wonder Woman work quickly to find and recruit a team of metahumans to stand against this newly awakened threat. But despite the formation of this unprecedented league of heroes-Batman, Wonder Woman, Aquaman, Cyborg and The Flash-it may already be too late to save the planet from an assault of catastrophic proportions.",
"description": "Fueled by his restored faith in humanity and inspired by Superman's selfless act, Bruce Wayne enlists the help of his newfound ally, Diana Prince, to face an even greater enemy.",
"writers": [
"Chris Terrio",
"Joss Whedon"
],
"stars": [
"Ben Affleck",
"Gal Gadot",
"Jason Momoa"
],
"poster": {
"large": "https://images-na.ssl-images-amazon.com/images/M/MV5BNDgwNjMwNjM1OV5BMl5BanBnXkFtZTgwNjA2Njk5MzI@._V1_.jpg",
"thumb": "https://images-na.ssl-images-amazon.com/images/M/MV5BNDgwNjMwNjM1OV5BMl5BanBnXkFtZTgwNjA2Njk5MzI@._V1_UX182_CR0,0,182,268_AL_.jpg"
}
}
for(var i = 0; i < imdb.cast.length; i++){
obj =
[
{
"full_name": imdb.cast[i].name,
"link": imdb.cast[i].link
},
]
console.log(obj)
}
This being displayed on the console:
15[Object Object]
Probably the example you posted in the question is not the same as you have in your application, so what I understood of the problem is that you concatenated a string (possibly) with an object.
– Guilherme Nascimento
Where are you creating the obj variable? If not, enter a var or Let before it. Then, a consolelog in the items individually to see the content. Can help.
– DiegoSantos
@Diegosantos I need to take the values 'name' and 'link' of 'cast' and put them in another json
– Maycon Benito
I answered below, see if it helps.
– DiegoSantos