當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
阿里fastjson 对象转JSON
生活随笔
收集整理的這篇文章主要介紹了
阿里fastjson 对象转JSON
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
引入阿里fostjson庫
dependencies {compile 'com.alibaba:fastjson:1.2.23' }LoginBeen實體類
package com.example.scxx.scbluetoothpay.been;import com.alibaba.fastjson.annotation.JSONType;/*** FileName:LoginBeen* Description:* Company:上海XX信息* User:weijia* Email:weijiagithub@gmail.com* Time: 2017-01-03 21:09* UpdateTime:*/@JSONType(orders = { "LoginName", "LoginPwd"}) public class LoginBeen {private String LoginName;private String LoginPwd;public void setLoginName(String LoginName){this.LoginName = LoginName;}public String getLoginName(){return this.LoginName;}public void setLoginPwd(String LoginPwd){this.LoginPwd = LoginPwd;}public String getLoginPwd(){return this.LoginPwd;}}//fastjson將實體類對象轉換為JSON(loginUsername,loginUserpwd是獲取鍵盤錄入獲取的數據)
//fastjson將實體類對象轉換為JSONLoginBeen loginBeen = new LoginBeen();loginBeen.setLoginName(loginUsername);loginBeen.setLoginPwd(loginUserpwd);String jsonstring = JSON.toJSONString(loginBeen);System.out.println("jsonstring--------"+jsonstring);總結
以上是生活随笔為你收集整理的阿里fastjson 对象转JSON的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【转】【Linux】linux awk命
- 下一篇: java对象转json