关闭

java控制台如何把一个对象的信息打印出来?

3169人阅读 评论(0) 收藏 举报
分类:

java控制台如何把一个对象的信息打印出来?


1、先引入任意一款对象转化成Jason的工具的jar包,

2、再通过 

System.out.println(jSONObject);   //打印该jason对象


3、打印结果大致如下:

{"amount":0,"echoCode":"","echoMessage":"","favAmount":0,"favApportion":"0","goodsfavList":[],"payAmount":0.01,"payChannel":{"code":"bestPay","name":"翼支付"},"payGdSubLineList":[],"payMentResult":null,"payNo":"","payState":"2"}



本人项目的测试代码大致如下:

/*
 * -------------------------------------------------------
 * Copyright (c) 2016 cominfo
 * All rights reserved.
 * 
 * FileName:PayMentFacadeTest.java
 * Description:PayMentFacadeTest
 * History:
 * Date           Author               Desc
 * 2016-05-10     wuxp
 * -------------------------------------------------------
 */
package com.hzcominfo.payment.facade.test;


import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.apache.commons.lang.StringUtils;


import com.hzcominfo.payment.base.BaseFacadeTest;
import com.hzcominfo.payment.context.Constants;
import com.hzcominfo.payment.facade.PayMentFacade;
import com.hzcominfo.payment.facade.dto.EmployeeDto;
import com.hzcominfo.payment.facade.dto.PayMentRequest;
import com.hzcominfo.payment.mapper.hd.HdPayMentRequest;
import com.hzcominfo.payment.mapper.hd.HdPayMentResponse;
import com.hzcominfo.payment.utils.PayMentUtils;
import com.hzcominfo.payment.utils.QueryRunable;


import net.butfly.albacore.exception.BusinessException;
import net.butfly.albacore.utils.more.JNDIUtils;
import net.sf.json.JSONObject;


/**
 * PayMentFacadeTest
 * @author wuxp
 * @version 1.0.0
 */
public class PayMentFacadeTest extends BaseFacadeTest<PayMentFacade> {
protected PayMentFacadeTest(Mode mode) throws Exception {
super(mode);
}


@Override
protected void doAllTest() throws BusinessException {

HdPayMentResponse hdPayMentResponse=this.facade.hdPaymentQuery(null,"100000000012");
JSONObject jSONObject=null;
jSONObject=JSONObject.fromObject(hdPayMentResponse);
System.out.println(jSONObject);

}


public static void main(String args[]) throws Exception {
JNDIUtils.attachContext("context.xml");
run(Mode.LOCAL);
System.exit(0);
}
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:512869次
    • 积分:7583
    • 等级:
    • 排名:第2814名
    • 原创:217篇
    • 转载:295篇
    • 译文:22篇
    • 评论:62条
    最新评论