Jsoncpp 使用以及 讀寫中文漢字unicode亂碼解決


遍歷json value

#include "json.h"    
typedef Json::Writer JsonWriter;    
typedef Json::Reader JsonReader;    
typedef Json::Value  JsonValue;           
void print(JsonValue v)    
{        
    JsonValue::Members mem = v.getMemberNames();        
    for (auto iter = mem.begin(); iter != mem.end(); iter++)        
    {            
        cout<<*iter<<"\t: ";            
        if (v[*iter].type() == Json::objectValue)            
        {                
            cout<<endl;                
            print(v[*iter]);            
        }            
        else if (v[*iter].type() == Json::arrayValue)            
        {                
            cout<<endl;                
            auto cnt = v[*iter].size();                
            for (auto i = 0; i < cnt; i++)                
            {                    
                print(v[*iter][i]);                
            }            
        }            
        else if (v[*iter].type() == Json::stringValue)            
        {                
            cout<<v[*iter].asString()<<endl;            
        }            
        else if (v[*iter].type() == Json::realValue)            
        {                
            cout<<v[*iter].asDouble()<<endl;            
        }            
        else if (v[*iter].type() == Json::uintValue)            
        {                
            cout<<v[*iter].asUInt()<<endl;            
        }            
        else          
        {                
            cout<<v[*iter].asInt()<<endl;            
        }        
    }        
    return;    
}   

json寫入文件unicode編碼解決辦法:https://blog.csdn.net/SomeOneMT5/article/details/108288240


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM