zoukankan      html  css  js  c++  java
  • object to 字符串json

     1 package com.beijxing.TestMain;
     2 
     3 import com.beijxing.entity.Student;
     4 import com.google.gson.Gson;
     5 import com.google.gson.annotations.SerializedName;
     6 
     7 /** 
     8 * 
     9 * @author 作者 : ywp
    10 * @version 创建时间:2016年10月30日 下午9:21:33 
    11 */
    12 public class TestGson1 {
    13     public static void main(String[] args) {
    14         testGson();
    15     }
    16     public static void testGson(){
    17         Student student = new Student();
    18         student.setId(1);
    19         student.setName("杨文培");
    20         student.setSex("男");
    21         //student.setAge(23);
    22         student.setBirthday("1993-01-23");
    23         Gson gson = new Gson();
    24         System.out.println(gson.toJson(student));
    25     }
    26 }
  • 相关阅读:
    java浅谈
    学习心得 六 修改
    学习心得 六
    学习心得 五
    学习心得 四
    学习java心得 三
    学习java心得 二
    学习java心得 一
    学习前言
    课程进展
  • 原文地址:https://www.cnblogs.com/yangly/p/6014174.html
Copyright © 2011-2022 走看看