我正在为我的投资组合建立一个电影库,目前我只有20个对象用于电影标题和摘要的JSON数组。做到这一点,当我点击物品时,可以说自杀队,并且比名字出现在网址中。 像这样,http://localhost:63342/Movie/title_of_the_movie如何从数组中的JSON对象获取属性值,然后写入url
很高兴在js或jquery中做到这一点。
[
{
"name": "Godzilla",
"year": 1998,
"releaseDate": "20 May 1988",
"runtime": "2h 19mm",
"director": "Roland Emmerich",
"screenplay": "Dean Devlin and Roland Emmerich",
"cast": {
"Matthew Broderick": "Dr.Niko Tatopolous",
"Jean Reno": "Philipe Roache",
"Maria Pitillo": "Audrey Timmonds",
"Hank Azaria": "Victor 'Animal' Palotti",
"Kevin Dunn": "Colonel Hicks",
"Michael Lerner": "Mayor Ebert",
"Harry Shearer": "Charles Caiman",
"Arabella field": "Lucy Palotti",
"Vicki Lewis": "Dr.Elsie Chapman",
"Doug Savant": "Sergeant O'Neal"
},
"castPhoto": {},
"imdb": 5.3,
"boxOffice": "$130,000,000 ",
"openingWeekend": "$55,726,951"
}
]
你也应该在这里显示你的JSON数组。你应该提到更多的细节 –
你应该通过encodeURIComponent()函数传递你的标题,然后将它添加到url中。 – nikhil