Code Monkey home page Code Monkey logo

jsoncpp's Introduction

1. 关于jsoncpp

本项目修改自 open-source-parsers/jsoncpp,版本号1.9.5

主要是为了更好的支持UTF8字符的显示。

2. 修改内容

  • Json::Value类,修改toStyledString()函数签名,新增参数settings
String toStyledString(const Json::Value& settings = Json::nullValue) const;
  • Json::StreamWriterBuilder类,新增setSettings()方法,函数签名如下。
void setSettings(const Json::Value& setting);
  • Json::FastWriter类,新增dropNullKeyValues_emitUTF8_两个私有属性,以及对应的dropNullKeyValues()emitUTF8()方法。

    • dropNullKeyValues: 如果某个key对应的valuenull,序列化为字符串时忽略该键值。

      // JSON对象
      {
          "age": 12,
          "name": "Tom",
          "data": null
      }
      
      // 输出字符串
      // data属性被移除
      {"age":12,"name":"Tom"}
    • emitUTF8: 启用UTF8编码。

      // 不启用
      {"name":"\u7f16\u7a0b","score":98}
      
      // 启用
      {"name":"编程","score":98}

3. 示例

example/main.cpp源文件。

4.1 编译(Linux平台)

# x86_64
make

# arm64(交叉编译)
make CXX=aarch64-linux-gnu-g++ AR=aarch64-linux-gnu-ar ARCH=aarch64

输出如下文件

  • lib/linux/libjsonccp.a: 静态库文件
  • example.out: 示例程序。(运行方式:./example.out)

4.2 编译(Windows平台)

打开win-vsproj/jsoncpp.sln项目,编译即可。

输出如下文件

  • lib/windows/$(Platform)/$(Configuration)/jsoncpp.lib: 静态库文件
  • example.exe: 示例程序。

jsoncpp's People

Contributors

leopard-c avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

xibeilang524

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.