Java转换为JSON首字母大写

最近调接口,入参JSON首字母需大写,步骤如下:

1.

package com.ceair.pojo;

import java.io.Serializable;
import java.util.List;

import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonAutoDetect(JsonMethod.FIELD)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class FlightBookingRequest implements Serializable {
	 /**
	 * 
	 */
	private static final long serialVersionUID = -7600859899586249635L;
	@JsonProperty("Account") 
	private String account ; 		//B2T用户名
	
	@JsonProperty("AgentName") 
	private String AgentName; 		//机构名称
	
	@JsonProperty("ContactName")
	private String ContactName; 	//联系人姓名
	
	@JsonProperty("ContactEmail")
	private String ContactEmail; 	//联系人邮箱
	
	@JsonProperty("ContactPhone")
	private String ContactPhone; 	//联系人电话
	
	@JsonProperty("PassengerPhone")
	private String PassengerPhone; 	//旅客联系电话
	
	@JsonProperty("ExtRefNo")
	private String ExtRefNo; 		//外部订单
	
	@JsonProperty("BookingChannel")
	private Integer BookingChannel; 	//预定方式
	
	@JsonProperty("FlightType")
	private String FlightType; 		//航班类型
	
	@JsonProperty("PnrCode")
	private String PnrCode; 		//旅客订座编号
	
	@JsonProperty("ListSegmentInfo")
	private List ListSegmentInfo; 	//航段信息
	
	@JsonProperty("ListPassengerInfo")
	private List ListPassengerInfo; 		//旅客信息
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getAgentName() {
		return AgentName;
	}
	public void setAgentName(String agentName) {
		AgentName = agentName;
	}
	public String getContactName() {
		return ContactName;
	}
	public void setContactName(String contactName) {
		ContactName = contactName;
	}
	public String getContactEmail() {
		return ContactEmail;
	}
	public void setContactEmail(String contactEmail) {
		ContactEmail = contactEmail;
	}
	public String getContactPhone() {
		return ContactPhone;
	}
	public void setContactPhone(String contactPhone) {
		ContactPhone = contactPhone;
	}
	public String getPassengerPhone() {
		return PassengerPhone;
	}
	public void setPassengerPhone(String passengerPhone) {
		PassengerPhone = passengerPhone;
	}
	public String getExtRefNo() {
		return ExtRefNo;
	}
	public void setExtRefNo(String extRefNo) {
		ExtRefNo = extRefNo;
	}
	public Integer getBookingChannel() {
		return BookingChannel;
	}
	public void setBookingChannel(Integer bookingChannel) {
		BookingChannel = bookingChannel;
	}
	public String getFlightType() {
		return FlightType;
	}
	public void setFlightType(String flightType) {
		FlightType = flightType;
	}
	public String getPnrCode() {
		return PnrCode;
	}
	public void setPnrCode(String pnrCode) {
		PnrCode = pnrCode;
	}
	public List getListSegmentInfo() {
		return ListSegmentInfo;
	}
	public void setListSegmentInfo(List listSegmentInfo) {
		ListSegmentInfo = listSegmentInfo;
	}
	public List getListPassengerInfo() {
		return ListPassengerInfo;
	}
	public void setListPassengerInfo(List listPassengerInfo) {
		ListPassengerInfo = listPassengerInfo;
	}
	
}

注:@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)是Java转换为json时null不显示

2.

//调用b2t预定接口
			ObjectMapper map = new ObjectMapper();
			String param = map.writeValueAsString(flight);




你可能感兴趣的:(java)