zoukankan      html  css  js  c++  java
  • 数据对象如何定义为Java代码示例

    想将数据保存为这样子:

    [{
    		"subject": {
    			"code": "B123",
    			"words": [{
    				"key": "gjc1",
    				"wight": 9.8,
    				"ct": 1575126920
    			}, {
    				"key": "gjc1",
    				"wight": 9.8,
    				"ct": 1575126920
    			}, {
    				"key": "gjc1",
    				"wight": 9.8,
    				"ct": 1575126920
    			}],
    			"wight": 3,
    			"ct": 1575126920
    		}
    	}, {
    		"subject": {
    			"code": "C456",
    			"words": [{
    				"key": "gjc1",
    				"wight": 9.8,
    				"ct": 1575126920
    			}, {
    				"key": "gjc1",
    				"wight": 9.8,
    				"ct": 1575126920
    			}, {
    				"key": "gjc1",
    				"wight": 9.8,
    				"ct": 1575126920
    			}],
    			"wight": 3,
    			"ct": 1575126920
    		}
    	}
    
    ]
    

      

    转换为Java后,如:

    /**
      * Copyright 2019 bejson.com 
      */
    package com.besjon.pojo;
    
    /**
     * Auto-generated: 2019-11-30 23:24:14
     *
     * @author bejson.com (i@bejson.com)
     * @website http://www.bejson.com/java2pojo/
     */
    public class JsonRootBean {
    
        private Subject subject;
        public void setSubject(Subject subject) {
             this.subject = subject;
         }
         public Subject getSubject() {
             return subject;
         }
    
    }
    
    /**
      * Copyright 2019 bejson.com 
      */
    package com.besjon.pojo;
    import java.util.List;
    
    /**
     * Auto-generated: 2019-11-30 23:24:14
     *
     * @author bejson.com (i@bejson.com)
     * @website http://www.bejson.com/java2pojo/
     */
    public class Subject {
    
        private String code;
        private List<Words> words;
        private int wight;
        private long ct;
        public void setCode(String code) {
             this.code = code;
         }
         public String getCode() {
             return code;
         }
    
        public void setWords(List<Words> words) {
             this.words = words;
         }
         public List<Words> getWords() {
             return words;
         }
    
        public void setWight(int wight) {
             this.wight = wight;
         }
         public int getWight() {
             return wight;
         }
    
        public void setCt(long ct) {
             this.ct = ct;
         }
         public long getCt() {
             return ct;
         }
    
    }
    

      

    /**
      * Copyright 2019 bejson.com 
      */
    package com.besjon.pojo;
    
    /**
     * Auto-generated: 2019-11-30 23:24:14
     *
     * @author bejson.com (i@bejson.com)
     * @website http://www.bejson.com/java2pojo/
     */
    public class Words {
    
        private String key;
        private double wight;
        private long ct;
        public void setKey(String key) {
             this.key = key;
         }
         public String getKey() {
             return key;
         }
    
        public void setWight(double wight) {
             this.wight = wight;
         }
         public double getWight() {
             return wight;
         }
    
        public void setCt(long ct) {
             this.ct = ct;
         }
         public long getCt() {
             return ct;
         }
    
    }
    

      

    直此,完成!!!

      

  • 相关阅读:
    安装vs2012后sql2008配置管理出错
    教你台式机如何接双显示器
    去除Office 2010的右键“共享文件夹同步”菜单
    内网的用户不能用外网IP访问内网
    VMware Workstation 8的简明使用教程
    EntityFramework4.0中遇到New transaction is not allowed because there are other threads running in the session
    几条软件开发心得
    .net各版本反射多种方法介绍
    .net4.0下的Lazy<T>类型简单应用
    使用DebugView小工具调试已部署的.net程序
  • 原文地址:https://www.cnblogs.com/wangqiideal/p/11964556.html
Copyright © 2011-2022 走看看