75. Serializing data to JSON

Write a program that can serialize a list of movies, as defined for the previous problems, to a JSON file. Each movie has a numerical identifier, title, release year, length in minutes, a list of directors, a list of writers, and a list of casting roles with actor name and character name. The following is an example of the expected JSON format:

{  "movies": [{    "id": 9871,    "title": "Forrest Gump",    "year": 1994,    "length": 202,    "cast": [{        "star": "Tom Hanks",        "name": "Forrest Gump"      },      {        "star": "Sally Field",        "name": "Mrs. Gump"      },      {        "star": "Robin Wright",        "name": "Jenny Curran"      },      {        "star": "Mykelti Williamson",        "name": "Bubba Blue"      }    ],    "directors": ["Robert Zemeckis"], "writers": ["Winston Groom", "Eric Roth"] ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.