C++ Web 框架 paozhu 1.3.0 发布

85 阅读1分钟

c++ 快速开发 web 框架 经过实际项目开发,根据反馈和修复, 已经发布 1.3.0 版

paozhu 框架 集成 ORM HTTP/2 功能,压力测试可以平稳运行。

github.com/hggq/paozhu

1.3.0 版更新内容

新版添加了 结构体或类对象 json_encode json_decode 功能

支持结构体嵌套和组合使用,可以反射输出 JSON 或 把 JSON 解析到对象

比如如下结构体

namespace psy
{ 
//@reflect json to_json from_json
struct department_outjson_t
{
  unsigned int id          = 0;
  unsigned int key         = 0;
  unsigned int value       = 0;
  unsigned int parentid    = 0;
  unsigned int bianzhi_num = 0;
  bool isopen              = true;
  bool _is_use             = false;
  std::string title;
  std::string desc;
  std::vector<department_outjson_t> children;
  std::string to_json(std::string aa="",int offset=0);
  unsigned int from_json()
  {
        //**aaaaa
        /*
        aaaa [][}]
        */
        char b='}';
        if(b=='{')
        {
            std::cout<<"assss}sss}{ssss}sss}"<<std::endl;
        }
        return 0;
  }
};

//@reflect json to_json from_json
struct department_listoutjson_t
{
  unsigned int code=0;
  struct department_tables
  {
    std::vector<department_outjson_t> list;
    unsigned int total=0;
  } data;
  std::vector<std::vector<std::string>> names;
};

} // namespace psy

使用方式

  std::string jsondep_str = psy::json_encode(depout_data);

  psy::department_listoutjson_t new_depout_data;
  psy::json_decode(new_depout_data, jsondep_str);
 
  std::string jsondep_str_temp = psy::json_encode(new_depout_data);

原文