C
C#13mo ago
Krzak

❔ ✅ Manipulating JSON

I'm using MediaWiki API to receive information about movies. From that I need to extract movie titles and page IDs to use them to get their specific sites and extract when the movie was made, the initial response doesn't contain this information. Finally, the title and year will be displayed in a list on a web page. That's quite a lot of information to process so I got a bit lost in there 🤔
6 Replies
Krzak
Krzak13mo ago
{
"batchcomplete": "",
"continue": {
"sroffset": 10,
"continue": "-||"
},
"query": {
"searchinfo": {
"totalhits": 12
},
"search": [
{
"ns": 0,
"title": "Shrek",
"pageid": 357,
"size": 4924,
"wordcount": 615,
"snippet": "|tytuł= <span class='searchmatch'>Shrek</span>\n|plakat= <span class='searchmatch'>Shrek</span>.jpg\n",
"timestamp": "2023-05-15T13:10:47Z"
},
{
"ns": 0,
"title": "Shrek 2",
"pageid": 358,
"size": 4836,
"wordcount": 623,
"snippet": "|tytuł= <span class='searchmatch'>Shrek</span> 2\n|plakat= <span class='searchmatch'>Shrek</span> 2.jpg\n",
"timestamp": "2023-06-10T15:32:33Z"
},
{
"ns": 0,
"title": "Shrek Trzeci",
"pageid": 359,
"size": 5924,
"wordcount": 685,
"snippet": "|tytuł= <span class='searchmatch'>Shrek</span> Trzeci\n|tytuł oryginalny= <span class='searchmatch'>Shrek</span> the Third\n",
"timestamp": "2023-05-15T17:50:21Z"
},
//I had to shorten the message, there's only more titles below
]
}
}
{
"batchcomplete": "",
"continue": {
"sroffset": 10,
"continue": "-||"
},
"query": {
"searchinfo": {
"totalhits": 12
},
"search": [
{
"ns": 0,
"title": "Shrek",
"pageid": 357,
"size": 4924,
"wordcount": 615,
"snippet": "|tytuł= <span class='searchmatch'>Shrek</span>\n|plakat= <span class='searchmatch'>Shrek</span>.jpg\n",
"timestamp": "2023-05-15T13:10:47Z"
},
{
"ns": 0,
"title": "Shrek 2",
"pageid": 358,
"size": 4836,
"wordcount": 623,
"snippet": "|tytuł= <span class='searchmatch'>Shrek</span> 2\n|plakat= <span class='searchmatch'>Shrek</span> 2.jpg\n",
"timestamp": "2023-06-10T15:32:33Z"
},
{
"ns": 0,
"title": "Shrek Trzeci",
"pageid": 359,
"size": 5924,
"wordcount": 685,
"snippet": "|tytuł= <span class='searchmatch'>Shrek</span> Trzeci\n|tytuł oryginalny= <span class='searchmatch'>Shrek</span> the Third\n",
"timestamp": "2023-05-15T17:50:21Z"
},
//I had to shorten the message, there's only more titles below
]
}
}
I have a model class for deserializing this too I'm not sure if it's even a good idea because I'd have to make the call for each of the movies for the production date and that seems like a lot of traffic, I tried to find a different API but filmweb isn't publicly available and imdb is restricted, I'm not exactly a movie person .-. unleeessss wikipedia? Anyway my first guess to make things easy would be to make each of the movies a separate object but maybe there's a better way
Angius
Angius13mo ago
I mean, yeah, each movie should be a separate instance of Movie
Krzak
Krzak13mo ago
just wondering, how to store them since they won't be named? In a list maybe? (it's a smol brain day today, sorry)
Angius
Angius13mo ago
Sure, a list works
Krzak
Krzak13mo ago
it works just fine but uh oh now I see that a list isn't clickable the same way a button is? I thought that I could just make them clickable and get informations about the selected movie from the dubbingpedia so like, attach an event that'd send a request but that seems to not be possible and I can't use <a href=""> because I don't know the exact links and I'd have to download the entire page's source anyway
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.