jsoncpp操作 json
- #include <iostream>
- //#include "json/json.h"
- #include "json_reader.cpp"
- #include "json_value.cpp"
- #include "json_writer.cpp"
- using namespace std;
- using namespace Json;
- int main(int argc, char *argv[])
- {
- // Configuration options
- char *config_doc=" { \"encoding\" :\"UTF-8\",\"plug-ins\" : [\"python\",\"c++\",\"ruby\"],\"indent\" : { \"length\" : 3, \"use_space\": true }}";
- Json::Value root; // will contains the root value after parsing.
- Json::Reader reader;
- bool parsingSuccessful = reader.parse( config_doc, root );
- if ( !parsingSuccessful )
- {
- // report to the user the failure and their locations in the document.
- std::cout << "Failed to parse configuration\n"
- << reader.getFormattedErrorMessages();
- return 1;
- }
- reader.parse(config_doc,root,false); //解析出json放到json中
- std::string encoding = root.get("encoding", "GBK" ).asString();
- const Json::Value plugins = root["plug-ins"];
- for(int index = 0; index < plugins.size(); ++index ){
- cout<<plugins[index];
- }
- cout<< plugins;
- cout<<encoding<<endl;
- root["encoding"] = "GB2312";
- root["indent"]["length"] = 5;
- root["indent"]["use_space"] = false;
- Json::StyledWriter writer;
- std::string outputConfig = writer.write( root );
- cout<<outputConfig;
- system("PAUSE");
- return 0;
- }
jsoncpp操作 json的更多相关文章
- JsonCpp操作数组对象
JsonCpp操作数组对象 概述 Json格式数据中,除了简单的String类型和一些非String类型,也有像各种高级语言中的数组类型一般的数组对象,且Json数组在实际开发中使用频率也比较高, ...
- 基于开源库jsoncpp的json字符串解析
json(JavaScript Object Notation)是一种轻量级高效数据交换格式.相比于XML,其更加简洁,解析更加方便.在实习期间,我负责的程序模块,多次使用到json进行数据传输.由于 ...
- 让C#可以像Javascript一样操作Json
Json的简介 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. JSON采用完全独立于语言的文本格式,但是也使用了 ...
- JavaScript操作JSON的方法总结,JSON字符串转换为JSON对象
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...
- C# 技巧(3) C# 操作 JSON
RestAPI中, 经常需要操作json字符串, 需要把json字符串"反序列化"成一个对象, 也需要把一个对象"序列化"成一字符串. C# 操作json, ...
- JS操作JSON总结
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...
- C#操作JSON
http://www.cnblogs.com/LiZhiW/p/3624729.html C#操作JSON 1. .NET对JSON的支持介绍............................. ...
- JSON和GSON操作json数据
1,JSON操作json import net.sf.json.JSONArray; import net.sf.json.JSONObject; //json操作数据 public static S ...
- js之操作JSON数据
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...
随机推荐
- C++学习笔记24:makefile文件
makefile make命令:负责c/c++程序编译与链接 make根据指定命令进行建构 建构规则文件:GNUmakefile , makefile,Makefile makefile 文件格式 m ...
- HC系列蓝牙模块连接单片机与电脑,传输数据(蓝牙心电测试)
毕设做无线心电监护.有线的做出来了,AD8232+MCU+LabVIEW上位机.pcb还没时间搞,这个9*7*2.5cm拿来测试能用. 自己做了AD8232的模拟前端,打的板子还没到没法测试. 虽然比 ...
- Neo4j Cypher运行示例
示例来源: Neo4j in Action. 0 准备数据 0.1 node (user1 { name: 'John Johnson', type: 'User', email: 'jsmith@e ...
- 构建一个简单的WCF应用——WCF学习笔记(1)
通过<WCF全面解析>来知识分享....感谢蒋金楠老师@Artech 一.VS中构建解决方案 Client一个控制台程序模拟的客户端,引用Service.ServiceModel.dl ...
- html随记
姓名输入框:<input type="text" value="默认有值"/> 密码输入框:<input type="text&qu ...
- ExtAspNet和FineUI未将对象引用设置到对象的实例
要在web.config中加入 <configSections> <section name="ExtAspNet" type="ExtAspNet.C ...
- selenium之xpath定位和input文本
selenium之xpath定位和input文本 xpath简单定位: 打开浏览器的F12 在自己需要定位的元素的那里右键 选择copy->xpath selenium获取input下的文本: ...
- MapReduce的输入输出
mapper和reducer的划分 mapper的数量等于输入文件被划分成的分块数,这取决于输入文件的大小以及文件块的大小.一个map操作只处理一个输入分片.运行作业的客户端通过调用getSplits ...
- java的读文件操作
java读取文件内容,可以作如下理解: 首先获得一个文件句柄,File file = new File():file即为文件句柄.两人之间联通电话网络了,就可以开始打电话了. 通过这条线路读取甲方的信 ...
- Cannot find executable for CFBundle 解决办法
出错日志为:2013-12-29 01:17:49.785 Displaying Alerts with UIAlertView[419:70b] Cannot find executable for ...