java java解析soap 返回xmlxml转model的时候,如果model里有字段名称首字母为大写,则该字段的值转不出来

98499人阅读
java(115)
Java解析XML的四种方法详解
XML现在已经成为一种通用的数据交换格式,平台的无关性使得很多场合都需要用到XML。本文将详细介绍用Java解析XML的四种方法
在做一般的XML数据交换过程中,我更乐意传递XML字符串,而不是格式化的XML Document。这就涉及到XML字符串和Xml Document的转换问题,说白了这是个很简单的问题,本文就各种XML解析器分别列举如下,以方便自己今后查阅。
=======================哈哈====================================
一、使用最原始的javax.xml.parsers,标准的jdk api
// 字符串转XML
String xmlStr = &......&;
StringReader sr = new StringReader(xmlStr);&
InputSource is = new InputSource(sr);&
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();&
DocumentBuilder builder=factory.newDocumentBuilder();&
Document doc = builder.parse(is);
//XML转字符串
TransformerFactory& tf& =& TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.setOutputProperty(&encoding&,&GB23121&);//解决中文问题,试过用GBK不行
ByteArrayOutputStream& bos& =& new& ByteArrayOutputStream();
t.transform(new DOMSource(doc), new StreamResult(bos));
String xmlStr = bos.toString();
这里的XML DOCUMENT为org.w3c.dom.Document
二、使用dom4j后程序变得更简单
// 字符串转XML
String xmlStr = &......&;
Document document = DocumentHelper.parseText(xmlStr);
// XML转字符串&
Document document = ...;
String text = document.asXML();
这里的XML DOCUMENT为org.dom4j.Document
三、使用JDOM
JDOM的处理方式和第一种方法处理非常类似
//字符串转XML
String xmlStr = &.....&;
StringReader sr = new StringReader(xmlStr);
InputSource is = new InputSource(sr);
Document doc = (new SAXBuilder()).build(is);
//XML转字符串
Format format = Format.getPrettyFormat();
format.setEncoding(&gb2312&);//设置xml文件的字符为gb2312,解决中文问题
XMLOutputter xmlout = new XMLOutputter(format);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
xmlout.output(doc,bo);
String xmlStr = bo.toString();
这里的XML DOCUMENT为org.jdom.Document
四、JAVASCRIPT中的处理
//字符串转XML
var xmlStr = &.....&;
var xmlDoc = new ActiveXObject(&Microsoft.XMLDOM&);
xmlDoc.async=
xmlDoc.loadXML(xmlStr);
//可以处理这个xmlDoc了
var name = xmlDoc.selectSingleNode(&/person/name&);
alert(name.text);
//XML转字符串
var xmlDoc = ......;
var xmlStr = xmlDoc.xml
这里的XML DOCUMENT为javascript版的XMLDOM
=============================我是黄金的分割线===========================
XML现在已经成为一种通用的数据交换格式,它的平台无关性,语言无关性,系统无关性,给数据集成与交互带来了极大的方便。对于XML本身的语法知识与技术细节,需要阅读相关的技术文献,这里面包括的内容有DOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Extensible Stylesheet Language Transformations),具体可参阅w3c官方网站文档http://www.w3.org获取更多信息。&
XML在不同的语言里解析方式都是一样的,只不过实现的语法不同而已。基本的解析方式有两种,一种叫SAX,另一种叫DOM。SAX是基于事件流的解析,DOM是基于XML文档树结构的解析。假设我们XML的内容和结构如下:&
&?xml version=&1.0& encoding=&UTF-8&?&&
&employees&&
&employee&&
&name&ddviplinux&/name&&
&sex&m&/sex&&
&age&30&/age&&
&/employee&&
&/employees&&
本文使用JAVA语言来实现DOM与SAX的XML文档生成与解析。&
首先定义一个操作XML文档的接口XmlDocument 它定义了XML文档的建立与解析的接口。&
package com.alisoft.facepay.framework.&
* @author hongliang.dinghl&
* 定义XML文档建立与解析的接口&
public interface XmlDocument {&
* 建立XML文档&
* @param fileName 文件全路径名称&
public void createXml(String fileName);&
* 解析XML文档&
* @param fileName 文件全路径名称&
public void parserXml(String fileName);&
1.DOM生成和解析XML文档&
为 XML 文档的已解析版本定义了一组接口。解析器读入整个文档,然后构建一个驻留内存的树结构,然后代码就可以使用 DOM 接口来操作这个树结构。优点:整个文档树在内存中,便于操作;支持删除、修改、重新排列等多种功能;缺点:将整个文档调入内存(包括无用的节点),浪费时间和空间;使用场合:一旦解析了文档还需多次访问这些数据;硬件资源充足(内存、CPU)。&
package com.alisoft.facepay.framework.&
import java.io.FileInputS&
import java.io.FileNotFoundE&
import java.io.FileOutputS&
import java.io.IOE&
import java.io.InputS&
import java.io.PrintW&
import javax.xml.parsers.DocumentB&
import javax.xml.parsers.DocumentBuilderF&
import javax.xml.parsers.ParserConfigurationE&
import javax.xml.transform.OutputK&
import javax.xml.transform.T&
import javax.xml.transform.TransformerConfigurationE&
import javax.xml.transform.TransformerE&
import javax.xml.transform.TransformerF&
import javax.xml.transform.dom.DOMS&
import javax.xml.transform.stream.StreamR&
import org.w3c.dom.D&
import org.w3c.dom.E&
import org.w3c.dom.N&
import org.w3c.dom.NodeL&
import org.xml.sax.SAXE&
* @author hongliang.dinghl&
* DOM生成与解析XML文档&
public class DomDemo implements XmlDocument {&
private D&
private String fileN&
public void init() {&
DocumentBuilderFactory factory = DocumentBuilderFactory&
.newInstance();&
DocumentBuilder builder = factory.newDocumentBuilder();&
this.document = builder.newDocument();&
} catch (ParserConfigurationException e) {&
System.out.println(e.getMessage());&
public void createXml(String fileName) {&
Element root = this.document.createElement(&employees&);&
this.document.appendChild(root);&
Element employee = this.document.createElement(&employee&);&
Element name = this.document.createElement(&name&);&
name.appendChild(this.document.createTextNode(&丁宏亮&));&
employee.appendChild(name);&
Element sex = this.document.createElement(&sex&);&
sex.appendChild(this.document.createTextNode(&m&));&
employee.appendChild(sex);&
Element age = this.document.createElement(&age&);&
age.appendChild(this.document.createTextNode(&30&));&
employee.appendChild(age);&
root.appendChild(employee);&
TransformerFactory tf = TransformerFactory.newInstance();&
Transformer transformer = tf.newTransformer();&
DOMSource source = new DOMSource(document);&
transformer.setOutputProperty(OutputKeys.ENCODING, &gb2312&);&
transformer.setOutputProperty(OutputKeys.INDENT, &yes&);&
PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));&
StreamResult result = new StreamResult(pw);&
transformer.transform(source, result);&
System.out.println(&生成XML文件成功!&);&
} catch (TransformerConfigurationException e) {&
System.out.println(e.getMessage());&
} catch (IllegalArgumentException e) {&
System.out.println(e.getMessage());&
} catch (FileNotFoundException e) {&
System.out.println(e.getMessage());&
} catch (TransformerException e) {&
System.out.println(e.getMessage());&
public void parserXml(String fileName) {&
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();&
DocumentBuilder db = dbf.newDocumentBuilder();&
Document document = db.parse(fileName);&
NodeList employees = document.getChildNodes();&
for (int i = 0; i & employees.getLength(); i++) {&
Node employee = employees.item(i);&
NodeList employeeInfo = employee.getChildNodes();&
for (int j = 0; j & employeeInfo.getLength(); j++) {&
Node node = employeeInfo.item(j);&
NodeList employeeMeta = node.getChildNodes();&
for (int k = 0; k & employeeMeta.getLength(); k++) {&
System.out.println(employeeMeta.item(k).getNodeName()&
+ &:& + employeeMeta.item(k).getTextContent());&
System.out.println(&解析完毕&);&
} catch (FileNotFoundException e) {&
System.out.println(e.getMessage());&
} catch (ParserConfigurationException e) {&
System.out.println(e.getMessage());&
} catch (SAXException e) {&
System.out.println(e.getMessage());&
} catch (IOException e) {&
System.out.println(e.getMessage());&
2.SAX生成和解析XML文档&
为解决DOM的问题,出现了SAX。SAX ,事件驱动。当解析器发现元素开始、元素结束、文本、文档的开始或结束等时,发送事件,程序员编写响应这些事件的代码,保存数据。优点:不用事先调入整个文档,占用资源少;SAX解析器代码比DOM解析器代码小,适于Applet,下载。缺点:不是持久的;事件过后,若没保存数据,那么数据就丢了;无状态性;从事件中只能得到文本,但不知该文本属于哪个元素;使用场合:A只需XML文档的少量内容,很少回头访问;机器内存少;&
package com.alisoft.facepay.framework.&
import java.io.FileInputS&
import java.io.FileNotFoundE&
import java.io.IOE&
import java.io.InputS&
import javax.xml.parsers.ParserConfigurationE&
import javax.xml.parsers.SAXP&
import javax.xml.parsers.SAXParserF&
import org.xml.sax.A&
import org.xml.sax.SAXE&
import org.xml.sax.helpers.DefaultH&
* @author hongliang.dinghl&
* SAX文档解析&
public class SaxDemo implements XmlDocument {&
public void createXml(String fileName) {&
System.out.println(&&&&+filename+&&&&);&
public void parserXml(String fileName) {&
SAXParserFactory saxfac = SAXParserFactory.newInstance();&
SAXParser saxparser = saxfac.newSAXParser();&
InputStream is = new FileInputStream(fileName);&
saxparser.parse(is, new MySAXHandler());&
} catch (ParserConfigurationException e) {&
e.printStackTrace();&
} catch (SAXException e) {&
e.printStackTrace();&
} catch (FileNotFoundException e) {&
e.printStackTrace();&
} catch (IOException e) {&
e.printStackTrace();&
class MySAXHandler extends DefaultHandler {&
boolean hasAttribute =&
Attributes attributes =&
public void startDocument() throws SAXException {&
System.out.println(&文档开始打印了&);&
public void endDocument() throws SAXException {&
System.out.println(&文档打印结束了&);&
public void startElement(String uri, String localName, String qName,&
Attributes attributes) throws SAXException {&
if (qName.equals(&employees&)) {&
if (qName.equals(&employee&)) {&
System.out.println(qName);&
if (attributes.getLength() & 0) {&
this.attributes =&
this.hasAttribute =&
public void endElement(String uri, String localName, String qName)&
throws SAXException {&
if (hasAttribute && (attributes != null)) {&
for (int i = 0; i & attributes.getLength(); i++) {&
System.out.println(attributes.getQName(0)&
+ attributes.getValue(0));&
public void characters(char[] ch, int start, int length)&
throws SAXException {&
System.out.println(new String(ch, start, length));&
package com.alisoft.facepay.framework.&
import java.io.FileInputS&
import java.io.FileNotFoundE&
import java.io.IOE&
import java.io.InputS&
import javax.xml.parsers.ParserConfigurationE&
import javax.xml.parsers.SAXP&
import javax.xml.parsers.SAXParserF&
import org.xml.sax.A&
import org.xml.sax.SAXE&
import org.xml.sax.helpers.DefaultH&
* @author hongliang.dinghl&
* SAX文档解析&
public class SaxDemo implements XmlDocument {&
public void createXml(String fileName) {&
System.out.println(&&&&+filename+&&&&);&
public void parserXml(String fileName) {&
SAXParserFactory saxfac = SAXParserFactory.newInstance();&
SAXParser saxparser = saxfac.newSAXParser();&
InputStream is = new FileInputStream(fileName);&
saxparser.parse(is, new MySAXHandler());&
} catch (ParserConfigurationException e) {&
e.printStackTrace();&
} catch (SAXException e) {&
e.printStackTrace();&
} catch (FileNotFoundException e) {&
e.printStackTrace();&
} catch (IOException e) {&
e.printStackTrace();&
class MySAXHandler extends DefaultHandler {&
boolean hasAttribute =&
Attributes attributes =&
public void startDocument() throws SAXException {&
System.out.println(&文档开始打印了&);&
public void endDocument() throws SAXException {&
System.out.println(&文档打印结束了&);&
public void startElement(String uri, String localName, String qName,&
Attributes attributes) throws SAXException {&
if (qName.equals(&employees&)) {&
if (qName.equals(&employee&)) {&
System.out.println(qName);&
if (attributes.getLength() & 0) {&
this.attributes =&
this.hasAttribute =&
public void endElement(String uri, String localName, String qName)&
throws SAXException {&
if (hasAttribute && (attributes != null)) {&
for (int i = 0; i & attributes.getLength(); i++) {&
System.out.println(attributes.getQName(0)&
+ attributes.getValue(0));&
public void characters(char[] ch, int start, int length)&
throws SAXException {&
System.out.println(new String(ch, start, length));&
3.DOM4J生成和解析XML文档&
DOM4J 是一个非常非常优秀的Java XML API,具有性能优异、功能强大和极端易用使用的特点,同时它也是一个开放源代码的软件。如今你可以看到越来越多的 Java 软件都在使用 DOM4J 来读写 XML,特别值得一提的是连 Sun 的 JAXM 也在用 DOM4J。&
package com.alisoft.facepay.framework.&
import java.io.F&
import java.io.FileW&
import java.io.IOE&
import java.io.W&
import java.util.I&
import org.dom4j.D&
import org.dom4j.DocumentE&
import org.dom4j.DocumentH&
import org.dom4j.E&
import org.dom4j.io.SAXR&
import org.dom4j.io.XMLW&
* @author hongliang.dinghl&
* Dom4j 生成XML文档与解析XML文档&
public class Dom4jDemo implements XmlDocument {&
public void createXml(String fileName) {&
Document document = DocumentHelper.createDocument();&
Element employees=document.addElement(&employees&);&
Element employee=employees.addElement(&employee&);&
Element name= employee.addElement(&name&);&
name.setText(&ddvip&);&
Element sex=employee.addElement(&sex&);&
sex.setText(&m&);&
Element age=employee.addElement(&age&);&
age.setText(&29&);&
Writer fileWriter=new FileWriter(fileName);&
XMLWriter xmlWriter=new XMLWriter(fileWriter);&
xmlWriter.write(document);&
xmlWriter.close();&
} catch (IOException e) {&
System.out.println(e.getMessage());&
public void parserXml(String fileName) {&
File inputXml=new File(fileName);&
SAXReader saxReader = new SAXReader();&
Document document = saxReader.read(inputXml);&
Element employees=document.getRootElement();&
for(Iterator i = employees.elementIterator(); i.hasNext();){&
Element employee = (Element) i.next();&
for(Iterator j = employee.elementIterator(); j.hasNext();){&
Element node=(Element) j.next();&
System.out.println(node.getName()+&:&+node.getText());&
} catch (DocumentException e) {&
System.out.println(e.getMessage());&
System.out.println(&dom4j parserXml&);&
4.JDOM生成和解析XML&
为减少DOM、SAX的编码量,出现了JDOM;优点:20-80原则,极大减少了代码量。使用场合:要实现的功能简单,如解析、创建等,但在底层,JDOM还是使用SAX(最常用)、DOM、Xanan文档。&
package com.alisoft.facepay.framework.&
import java.io.FileNotFoundE&
import java.io.FileOutputS&
import java.io.IOE&
import java.util.L&
import org.jdom.D&
import org.jdom.E&
import org.jdom.JDOME&
import org.jdom.input.SAXB&
import org.jdom.output.XMLO&
* @author hongliang.dinghl&
* JDOM 生成与解析XML文档&
public class JDomDemo implements XmlDocument {&
public void createXml(String fileName) {&
root=new Element(&employees&);&
document=new Document(root);&
Element employee=new Element(&employee&);&
root.addContent(employee);&
Element name=new Element(&name&);&
name.setText(&ddvip&);&
employee.addContent(name);&
Element sex=new Element(&sex&);&
sex.setText(&m&);&
employee.addContent(sex);&
Element age=new Element(&age&);&
age.setText(&23&);&
employee.addContent(age);&
XMLOutputter XMLOut = new XMLOutputter();&
XMLOut.output(document, new FileOutputStream(fileName));&
} catch (FileNotFoundException e) {&
e.printStackTrace();&
} catch (IOException e) {&
e.printStackTrace();&
public void parserXml(String fileName) {&
SAXBuilder builder=new SAXBuilder(false);&
Document document=builder.build(fileName);&
Element employees=document.getRootElement();&
List employeeList=employees.getChildren(&employee&);&
for(int i=0;iElement employee=(Element)employeeList.get(i);&
List employeeInfo=employee.getChildren();&
for(int j=0;jSystem.out.println(((Element)employeeInfo.get(j)).getName()+&:&+((Element)employeeInfo.get(j)).getValue());&
} catch (JDOMException e) {&
e.printStackTrace();&
} catch (IOException e) {&
e.printStackTrace();&
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:705130次
积分:6643
积分:6643
排名:第3864名
原创:144篇
转载:219篇
评论:76条
(3)(6)(3)(2)(8)(7)(1)(2)(20)(5)(17)(1)(18)(21)(12)(7)(2)(21)(16)(12)(7)(8)(6)(10)(13)(13)(1)(9)(25)(26)(19)(5)(21)(1)(2)(1)(3)(2)(4)(1)(3)
(window.slotbydup = window.slotbydup || []).push({
id: '4740887',
container: s,
size: '250,250',
display: 'inlay-fix'Json 转Java对象时,遇到Key值首字母大写无法转换问题 - CSDN博客
Json 转Java对象时,遇到Key值首字母大写无法转换问题
&&&&& 今天在打印接口请求后返回响应时,因返回的json串中有个Key值的首字母大写,导致我在转Java对象时,该Key值转换失败。
转换的结果为:其中text 为转换前的Json 串& dataVo为转换后的结果,从图中可以看到Msg这个key值为进行转换
本人使用的是 【fastjson
从网上查了下好像如果Key值的首字母大写的转换不了,本人的解决方案是,在json转换之前,将key的值进行一下替换
String& result = {&Msg&:&用户手机号已存在&,&authKey&:&&,&result&:0}
然后进行转换
String resultData = result.replace(&Msg&, &msg&);
然后即解决了Key首字符大写不能转换的问题
本文已收录于以下专栏:
相关文章推荐
今天在做Docker的管理工具时,遇到一个解析JSON串的问题,由于Docker返回的JSON属性的首字母都为大写,如下
&Created&: ,...
import net.sf.json.JSONO
import net.sf.json.JsonC
import net.sf.json.util.JavaIdentifier...
java代码对象如下:package com.ctrip.market.messagepush.service.import com.fasterxml.jackson.annotati...
@JsonProperty
private int
在这种 字段加上@JsonProperty,然后在get 和set方法上加上@JsonProperty,如下
最近调接口,入参JSON首字母需大写,步骤如下:
package com.ceair.
import java.io.S
import java.util...
请求Json数据的时候,传递过去的String类型转Json数据的时候经常有首字母是大写的情况,例如&LoginAccount&:&02:00:00:62:73:74&,&LoginType&:&1&...
声明一个为汉字的不可变字符串NSString * str = @&这是一个汉字&;2)
将字符串转成c语言中的不可变字符串
CFStringRef strRef = (CFStringRe...
他的最新文章
讲师:宋宝华
讲师:何宇健
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)最近项目中需要对xml文件进行解析!有时候会遇到xml的节点大小写不一致的问题,因此写了个方法把xml文件中的节点全部转为大写的方式,在这里做个备忘。代码如下,
public static Element elementToUpper(Element ele){
ele.setName(ele.getName().toUpperCase());
List&Attribute& attrList = ele.getAttributes();
if(!attrList.isEmpty()){
for(int i=0, m = attrList.size(); i & i++){
Attribute attr = attrList.get(i);
attr.setName(attr.getName().toUpperCase());
List&Element& eleList = ele.getChildren();
if(!eleList.isEmpty()){
for(int i=0, m=eleList.size(); i&m; i++){
Element element = eleList.get(i);
element.setName(element.getName().toUpperCase());
elementToUpper(element);
下面这个是把xml文件中的值根据节点名称存放到Map中:
public static Map&String, String& getElementAll(Element ele){
Map&String, String& map = new HashMap&String, String&();
List&Attribute& attrList = ele.getAttributes();
if(!attrList.isEmpty()){
for(int i=0, m = attrList.size(); i & i++){
Attribute attr = attrList.get(i);
map.put(ele.getName().toUpperCase() + attr.getName().toUpperCase(), attr.getValue());
List&Element& eleList = ele.getChildren();
if(!eleList.isEmpty()){
for(int i=0, m=eleList.size(); i&m; i++){
Element element = eleList.get(i);
Map&String, String& eleMap = getElementAll(element);
mapPutAll(map, eleMap);
}else if(null != ele.getValue() && ele.getValue().length() & 0){
map.put(ele.getName().toUpperCase(), ele.getValue());
* 将源Map拷贝到目标Map当中
* 如果目标Map存在源Map中的对象,则在原key值上加上一个“_1”,如果还存在则“_2”,
* 如:key,key_1,key_2...
* @param target
* @param source
* @author kane xiang
private static Map&String, String& mapPutAll(Map&String, String& target, Map&String, String& source){
int num = 1;
boolean bool =
Iterator&Entry&String, String&& it = source.entrySet().iterator();
while(it.hasNext()){
Entry&String, String& entry = it.next();
if(null == target.get(entry.getKey())){
target.put(entry.getKey(), entry.getValue());
while(bool){
String key = entry.getKey() + "_" +
if(null == target.get(key)){
target.put(key, entry.getValue());
浏览: 18807 次
来自: 上海
后面总是加一列是怎么回事?
真是太感谢你了,你这个对我有很大的帮助。
不用 手动 关闭 session吧?
用 spring管理后, ...
是这样的,在Hibernate中
获取session的两种方式 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'Java转换为JSON首字母大写 - CSDN博客
Java转换为JSON首字母大写
最近调接口,入参JSON首字母需大写,步骤如下:
package com.ceair.
import java.io.S
import java.util.L
import org.codehaus.jackson.annotate.JsonAutoD
import org.codehaus.jackson.annotate.JsonM
import org.codehaus.jackson.annotate.JsonP
import org.codehaus.jackson.map.annotate.JsonS
@JsonAutoDetect(JsonMethod.FIELD)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class FlightBookingRequest implements Serializable {
private static final long serialVersionUID = -6249635L;
@JsonProperty(&Account&)
//B2T用户名
@JsonProperty(&AgentName&)
private String AgentN
//机构名称
@JsonProperty(&ContactName&)
private String ContactN
//联系人姓名
@JsonProperty(&ContactEmail&)
private String ContactE
//联系人邮箱
@JsonProperty(&ContactPhone&)
private String ContactP
//联系人电话
@JsonProperty(&PassengerPhone&)
private String PassengerP
//旅客联系电话
@JsonProperty(&ExtRefNo&)
private String ExtRefNo;
//外部订单
@JsonProperty(&BookingChannel&)
private Integer BookingC
//预定方式
@JsonProperty(&FlightType&)
private String FlightT
//航班类型
@JsonProperty(&PnrCode&)
private String PnrC
//旅客订座编号
@JsonProperty(&ListSegmentInfo&)
private List&SegmentInfo& ListSegmentI
//航段信息
@JsonProperty(&ListPassengerInfo&)
private List&PassengerInfo& ListPassengerI
//旅客信息
public String getAccount() {
public void setAccount(String account) {
this.account =
public String getAgentName() {
return AgentN
public void setAgentName(String agentName) {
AgentName = agentN
public String getContactName() {
return ContactN
public void setContactName(String contactName) {
ContactName = contactN
public String getContactEmail() {
return ContactE
public void setContactEmail(String contactEmail) {
ContactEmail = contactE
public String getContactPhone() {
return ContactP
public void setContactPhone(String contactPhone) {
ContactPhone = contactP
public String getPassengerPhone() {
return PassengerP
public void setPassengerPhone(String passengerPhone) {
PassengerPhone = passengerP
public String getExtRefNo() {
return ExtRefNo;
public void setExtRefNo(String extRefNo) {
ExtRefNo = extRefNo;
public Integer getBookingChannel() {
return BookingC
public void setBookingChannel(Integer bookingChannel) {
BookingChannel = bookingC
public String getFlightType() {
return FlightT
public void setFlightType(String flightType) {
FlightType = flightT
public String getPnrCode() {
return PnrC
public void setPnrCode(String pnrCode) {
PnrCode = pnrC
public List&SegmentInfo& getListSegmentInfo() {
return ListSegmentI
public void setListSegmentInfo(List&SegmentInfo& listSegmentInfo) {
ListSegmentInfo = listSegmentI
public List&PassengerInfo& getListPassengerInfo() {
return ListPassengerI
public void setListPassengerInfo(List&PassengerInfo& listPassengerInfo) {
ListPassengerInfo = listPassengerI
注:@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)是Java转换为json时null不显示
2.//调用b2t预定接口
ObjectMapper map = new ObjectMapper();
String param = map.writeValueAsString(flight);

本文已收录于以下专栏:
相关文章推荐
如图所示:
这种情况如果转为String s = JSON.toJSONString(model);
那么得到的字符串就会是{&oP_CODE&:&OP_REQ_USER_LOGIN&,&st...
最近在一个MVC5项目中遇到了一个问题:C#编码规范中规定属性的首字母是大写的(大多数公司采用这种编码风格),但是从其它系统中接收到的json对象的属性却是小写的(大多数公司采用这种编码风格),怎样才...
今天在做Docker的管理工具时,遇到一个解析JSON串的问题,由于Docker返回的JSON属性的首字母都为大写,如下
&Created&: ,...
最近项目中用到了spring boot然后,在接口返回的json串中有一些字段首字母是需要大写的。在听取同事的说明之后用@JSONField注解在属性上面可以解决。但是,无效….OK,然后了解到事实当...
fastjson输出字符串默认首字母小写,如果想要大写(和bean一致),需要使用如下配置。
patibleWithJavaBean =
最近在项目中调用.NET的服务时,Jackson在解析返回的json字符串时始终报错,纠结很久之后才找到原因,原来是是由于json字符串中的字母都是首字母大写,导致jackson找不到相应的KEY。
...
有时候我们会遇到实体的成员变量是大写的情况,而转换成JSON后首字母变成了小写,解决的办法是在实体的get方法上添加@JSONField(name = “XXX”),
我这里用的是fastjson ...
他的最新文章
讲师:宋宝华
讲师:何宇健
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)

我要回帖

更多关于 java sax解析xml 的文章

 

随机推荐