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;
         }
    
    }
    

      

    直此,完成!!!

      

  • 相关阅读:
    S1-概论
    AngularJS--day01介绍使用基本语法
    原生ajax--2
    原生ajax---1
    操作元素--字符串对象-日期对象-Array对象(数组)-Math对象-计时器
    HTTP协议系列教材 (三)- 通过Firefox火狐调试工具观察 HTTP 请求协议
    HTTP协议系列教材 (二)- 借助FireFox火狐调试工具学习HTTP协议
    HTTP协议系列教材 (一)- 教程
    Servlet系列教材 (二十七)- JSON
    Servlet系列教材 (二十六)- JSON
  • 原文地址:https://www.cnblogs.com/wangqiideal/p/11964556.html
Copyright © 2011-2022 走看看