Skip to content
/ autojson Public

autojson能够自动解析c++类语法,然后生成json序列化和反序列化的c++代码。生成的代码依赖rapidjson。

Notifications You must be signed in to change notification settings

bilc/autojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Autojson can generate cpp code for converting between cpp class and json. Its result code is based on rapidjson.

  • dev language: python
  • platforms: mac and linux
  • json character: utf8
  • dependency: libclang and rapidjson  

Install

generating tool need:
pip install clang

generated code need:
install https://github.com/miloyip/rapidjson

Supported Grammar

T can be basic data type(int,uint,long,float,double...), string, and user-defined class.
Container can be list, vector.

T i; 
T * i;  
Container< T> i; 
Container< T*> i; 
Container< T> * i;  
Map< string, T> i; 
Map< string, T*> i; 
Map< string, T> * i;  

Incompatible Grammar

  • c-style array like 'int a[10];' or 'char * str; int strLen;'. It should be 'vector a;' or 'string str;'.
  • container embed container, like vector< list< T>>
  • except list,vector and map, the other containers
  • user-defined template

Usage

encode.py file className
decode.py file className

generate file:
encode_className.h encode_className.cpp
decode_className.h decode_className.cpp

function:
void encode(className &x, std::string &s);
void decode(const char *s, className &x);

About

autojson能够自动解析c++类语法,然后生成json序列化和反序列化的c++代码。生成的代码依赖rapidjson。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published