• 数据对象如何定义为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;
         }
    
    }
    

      

    直此,完成!!!

      

  • 相关阅读:
    JS 数组去重复值
    git 上传项目 到github
    IntelliJ IDEA 创建maven 项目 并且,将springMVC 与Mybatis 整合
    easyui datagrid 动态添加columns属性
    codeMirror的简单使用,js比较文本差异(标注出增删改)
    sql注入
    Web For Pentester靶场
    一些数据库
    nginx的使用场景
    dockerfile
  • 原文地址:https://www.cnblogs.com/wangqiideal/p/11964556.html
Copyright © 2020-2023  润新知