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