zoukankan      html  css  js  c++  java
  • vjson.hpp

    //vov
    #ifndef VJSON_HPP
    #define VJSON_HPP
    
    #include <iostream>
    #include <string>
    #include "json.hpp"
    
    using vJson=nlohmann::json;
    
    bool  vJsonFromFile(vJson &json_data,const std::string& fname) {
        std::fstream ifs(fname,std::fstream::in);
        try {
            ifs>>json_data;
        }
        catch(std::exception &e) {
            std::cout<<"["<<__FUNCTION__<<"]"<<e.what()<<"
    ";
            ifs.close();
            return false;
        }
        ifs.close();
        return true;
    }
    
    bool vJsonToFile(vJson &json_data,const std::string& fname) {
        std::fstream ofs(fname,std::fstream::out);
        try {
            ofs<<json_data.dump(4);
        }
        catch(std::exception &e) {
            std::cout<<"["<<__FUNCTION__<<"]"<<e.what()<<"
    ";
            return false;
        }
        ofs.close();
        return true;
    }
    
    bool vJsonHasKey(vJson &json_data,const std::string &key) {
        return (json_data.find(key)!=json_data.end())?true:false;
    }
    
    #endif
    
  • 相关阅读:
    dp
    数学分析 + 容斥原理
    容斥
    并查集
    矩阵hash + KMP
    扫描线
    位运算
    2015 Multi-University Training Contest 5 1009 MZL's Border
    iOS ZipArchive文件解压缩
    iOS GCD倒计时
  • 原文地址:https://www.cnblogs.com/smallredness/p/10774989.html
Copyright © 2011-2022 走看看