当前位置: 首页 > news >正文

python给json 转实体类加注释的代码实现

1 通过 GsonFormatPlus 生成的实体类

package com.zcl;import java.util.List;public class Test{/*** org_code*/private String org_code;/*** code*/private String code;/*** name*/private NameDTO name;/*** vendorextends*/private VendorextendsDTO vendorextends;/*** taxPayingCategories*/private String taxPayingCategories;/*** vendorclass*/private String vendorclass;/*** country*/private String country;/*** id*/private String id;/*** _status*/private String _status;/*** vendorOrgs*/private List<VendorOrgsDTO> vendorOrgs;public String getOrg_code() {return org_code;}public void setOrg_code(String org_code) {this.org_code = org_code;}public String getCode() {return code;}public void setCode(String code) {this.code = code;}public NameDTO getName() {return name;}public void setName(NameDTO name) {this.name = name;}public VendorextendsDTO getVendorextends() {return vendorextends;}public void setVendorextends(VendorextendsDTO vendorextends) {this.vendorextends = vendorextends;}public String getTaxPayingCategories() {return taxPayingCategories;}public void setTaxPayingCategories(String taxPayingCategories) {this.taxPayingCategories = taxPayingCategories;}public String getVendorclass() {return vendorclass;}public void setVendorclass(String vendorclass) {this.vendorclass = vendorclass;}public String getCountry() {return country;}public void setCountry(String country) {this.country = country;}public String getId() {return id;}public void setId(String id) {this.id = id;}public String get_status() {return _status;}public void set_status(String _status) {this._status = _status;}public List<VendorOrgsDTO> getVendorOrgs() {return vendorOrgs;}public void setVendorOrgs(List<VendorOrgsDTO> vendorOrgs) {this.vendorOrgs = vendorOrgs;}public static class NameDTO {/*** zh_CN*/private String zh_CN;public String getZh_CN() {return zh_CN;}public void setZh_CN(String zh_CN) {this.zh_CN = zh_CN;}}public static class VendorextendsDTO {/*** _status*/private String _status;/*** simplename*/private SimplenameDTO simplename;/*** helpcode*/private String helpcode;public String get_status() {return _status;}public void set_status(String _status) {this._status = _status;}public SimplenameDTO getSimplename() {return simplename;}public void setSimplename(SimplenameDTO simplename) {this.simplename = simplename;}public String getHelpcode() {return helpcode;}public void setHelpcode(String helpcode) {this.helpcode = helpcode;}public static class SimplenameDTO {/*** zh_CN*/private String zh_CN;public String getZh_CN() {return zh_CN;}public void setZh_CN(String zh_CN) {this.zh_CN = zh_CN;}}}public static class VendorOrgsDTO {/*** id*/private String id;/*** org_code*/private String org_code;/*** _status*/private String _status;public String getId() {return id;}public void setId(String id) {this.id = id;}public String getOrg_code() {return org_code;}public void setOrg_code(String org_code) {this.org_code = org_code;}public String get_status() {return _status;}public void set_status(String _status) {this._status = _status;}}
}

2 加注释

#chinese.txt
org_code	管理组织ID
code	供应商编码
name	供应商名称zh_CN	中文
vendorclass	所属分类ID
vendorclass_code	所属分类编码
def txt_to_dict():# 读取txt文件内容with open('chinese.txt','r',encoding='utf-8') as f:lines = f.readlines()chinese = {}for line in lines:kv = line.split()chinese[kv[0]]=kv[1]return chinese
def  read_java(chinese):with open('entity.java','r') as f:content = f.read()for key in chinese:english = "* "+keychinese_word = "* "+chinese[key]# 替换属性注释content = content.replace(english, str(chinese_word))print(content)with open('entity2.java','w',encoding="utf-8") as w:w.write(content)
def main():chinese = txt_to_dict();read_java(chinese);
if __name__ == '__main__':main();
http://www.lryc.cn/news/164694.html

相关文章:

  • 绘制三角波与梯形波
  • 【Git】 git push 提示Not possible to fast-forward,无法提交也无法提交程序
  • 优思学院|为什么质量工程师在别人看是“救火“的呢?
  • VMware Explore | 联想与VMware扩大合作带来生成式AI和多云解决方案
  • 8月份徒弟企业面试后反馈的软件测试面试题(含金量高请收藏)
  • 私有云不是真正的云计算!
  • netperf 测试时延和吞吐
  • 安卓预制权限添加规则
  • D3JS简介
  • 系统架构设计师(第二版)学习笔记----系统工程
  • java spring cloud 企业工程管理系统源码+二次开发+定制化服务
  • IMX6ULL移植篇-boot 命令的学习
  • Python字典和集合操作指南:创建、获取值、修改和删除键值对,复制和遍历方法全解析
  • unity 接收拼接数据进行纹理替换且保存相机纹理到rtsp server(一)
  • 视频讲解|3014 含分布式电源的配电网优化重构
  • 分布式、锁、延时任务
  • Mojo 语言官网
  • JTS:02 使用WKB操作数据
  • stonedb部署实践
  • wsl使用apt install net-tools报错
  • python 使用requests爬取百度图片并显示
  • DataSecurity Plus:守护企业数据安全的坚实堡垒
  • 《树莓派4B家庭服务器搭建指南》第二十一期:安装开源远程桌面服务rustdesk, 内网丝滑,外网流畅控制
  • Redis 分布式锁
  • 水循环原理VR实景教学课件开发
  • [小尾巴 UI 组件库] 全屏响应式轮播背景图(基于 Vue 3 与 Element Plus)
  • 关于ESP32S3无法识别到端口问题
  • 如何判断bug是前端bug还是后端bug
  • EasyExcel填充数据EasyExcel填充数据流下载 easyexcel填充excel下载 easyexcel填充
  • 精通数据集成:轻易云数据集成平台应用实战与技术内幕