当前位置: 代码迷 >> JavaScript >> JSON首字母大写有关问题
  详细解决方案

JSON首字母大写有关问题

热度:148   发布时间:2012-09-28 00:03:35.0
JSON首字母大写问题
package com.jshx.uam.authReq.xml;

import java.io.IOException;

import net.sf.json.JSONObject;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

public class SessionHeader {
	
	@JsonProperty("ActionCode")
	private String ActionCode = "";
	
	@JsonProperty("TransactionID")
	private String TransactionID = "";
	
	@JsonProperty("RspTime")
	private String RspTime = "";
	
	@JsonProperty("DigitalSign")
	private String DigitalSign = "";
	
	@JsonProperty("Response")
	private Response Response; 
	
	public static void main(String[] args) throws JsonGenerationException, JsonMappingException, IOException {
SessionHeader sh = new SessionHeader();
sh.setActionCode("1");
	
		ObjectMapper mapper = new ObjectMapper(); 
		String json=mapper.writeValueAsString(sh);
		System.out.println(json); 
		
		sh=mapper.readValue(json, SessionHeader.class);
		System.out.println(sh.getActionCode());
	}
	
	@JsonIgnore
	public String getActionCode() {
		return ActionCode;
	}

	@JsonIgnore
	public void setActionCode(String actionCode) {
		ActionCode = actionCode;
	}

	@JsonIgnore
	public String getTransactionID() {
		return TransactionID;
	}

	@JsonIgnore
	public void setTransactionID(String transactionID) {
		TransactionID = transactionID;
	}

	@JsonIgnore
	public String getRspTime() {
		return RspTime;
	}

	@JsonIgnore
	public void setRspTime(String rspTime) {
		RspTime = rspTime;
	}

	@JsonIgnore
	public String getDigitalSign() {
		return DigitalSign;
	}

	@JsonIgnore
	public void setDigitalSign(String digitalSign) {
		DigitalSign = digitalSign;
	}

	@JsonIgnore
	public Response getResponse() {
		return Response;
	}

	@JsonIgnore
	public void setResponse(Response response) {
		Response = response;
	}
}

  相关解决方案