小编Cav*_*lan的帖子

如何使用 C++ 读取和使用 JSON 文件中的数据

我希望读取 JSON 文件并使用该信息来创建多项选择测验。我只是无法理解如何从 JSON 文件中实际读取它。我已经设法读对了问题的数量,但仅此而已。

这是我的 JSON 文件的当前布局:

{
    "numOfQues": 5,
    "questions": [
        {
            "question": "Who is the US President?",
            "options": [
              "Joe Biden",
              "Joe BIREN",
              "Joe Momma",
              "Joe Bein"
            ],
            "answer": 2
        },
        {
            "question": "Who scored the best goal in Puskas history?",
            "options": [
              "Erik Lamela",
              "Son Heung-Min",
              "Cristiano Ronaldo",
              "Wayne Rooney"
            ],
            "answer": 4
        },
        {
            "question": "Where should Lamela really have finished?",
            "options": [
              "First",
              "Second",
              "Third",
              "Fourth"
            ],
            "answer": 3
        },
        {
            "question": "What does …
Run Code Online (Sandbox Code Playgroud)

c++ json

2
推荐指数
1
解决办法
8177
查看次数

标签 统计

c++ ×1

json ×1