最近调接口,入参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<SegmentInfo> ListSegmentInfo; 	//航段信息
	
	@JsonProperty("ListPassengerInfo")
	private List<PassengerInfo> 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<SegmentInfo> getListSegmentInfo() {
		return ListSegmentInfo;
	}
	public void setListSegmentInfo(List<SegmentInfo> listSegmentInfo) {
		ListSegmentInfo = listSegmentInfo;
	}
	public List<PassengerInfo> getListPassengerInfo() {
		return ListPassengerInfo;
	}
	public void setListPassengerInfo(List<PassengerInfo> listPassengerInfo) {
		ListPassengerInfo = listPassengerInfo;
	}
	
}

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

2.

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



GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 4 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐