阿里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将实体类对象转换为JSON
                    LoginBeen loginBeen = new LoginBeen();
                    loginBeen.setLoginName(loginUsername);
                    loginBeen.setLoginPwd(loginUserpwd);

                    String jsonstring = JSON.toJSONString(loginBeen);
                    System.out.println("jsonstring--------"+jsonstring);
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值