Untitled

 avatar
unknown
plain_text
2 years ago
555 B
4
Indexable
#include <iostream>
#include <nlohmann/json.hpp>

int main() {
    std::string json_string = R"(
    {
        "game_dim":43,
        "game_state":"Running",
        "blue":"BLUE",
        "blue_heads":[[21,25],[21,24],[21,23]],
        "blue_score":0,
        "red":"RED",
        "red_heads":[[21,17],[21,18],[21,19]],
        "red_score":0
    })";

    nlohmann::json json_obj = nlohmann::json::parse(json_string);

    int game_dim = json_obj["game_dim"];
    std::cout << "game_dim: " << game_dim << std::endl;
    return 0;
}
Editor is loading...