I am pulling JSON output from the Open Movie Database linked here
In preparation for some analysis, I would like to re-order the Key:value pairs and write this output to a .txt file. The API gives me output in the following form:
{
"Plot": "A skilled extractor is offered a chance to regain his old life as payment for a task considered to be impossible.",
"Rated": "PG-13",
"Response": "True",
"Language": "English, Japanese, French",
"Title": "Inception",
"Country": "USA, UK",
"Writer": "Christopher Nolan",
"Metascore": "74",
"imdbRating": "8.8",
"Director": "Christopher Nolan",
"Released": "16 Jul 2010",
"Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
"Year": "2010",
"Genre": "Action, Adventure, Mystery",
"Awards": "Won 4 Oscars. Another 83 wins & 109 nominations.",
"Runtime": "148 min",
"Type": "movie",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg",
"imdbVotes": "912,048",
"imdbID": "tt1375666"
}
I would like to reorder the Key:Value pairs as such
Current Desired structure
Plot Title
Rated Year
Response Rated
Language Released
Title Runtime
Country Genre
Writer Director
Metascore Writer
imdbRating Actors
Director Plot
Released Language
Actors Country
Year Awards
Genre Poster
Awards Metascore
Runtime IMDB rating
Type IMDB Votes
Poster IMDB_ID
imdbVotes Type
imdbID Response
Since the python json.loads()
method turns the JSON schema into a dict, is there a simple/intuitive way to custom sort a new schema before I write this to my file, or will I need to write a for
loop to write these key:value pairs into a new dict?