#include <iostream>
      #include <nlohmann/json.hpp>
      #include <iomanip>
      #include <vector>
      #include <fstream>
      
      using json = nlohmann::json;
      int readJSON(){
        json i_data;
        std::vector<std::string> ids = i_data["id"];
        std::vector<int> counts = i_data["count"];
        json o_data;
        o_data["id"] = ids;
        o_data["count"] = counts;
        std::ofstream os("o_data.json");
        os << std::setw(4) << o_data << std::endl;
        std::cout << "write complete" << std::endl;
        return 0;
      }
      
      Cpp language logo

      Write JSON

      Codiga's C++ Recipes

      Use nlohmann lib to write JSON

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.