当前位置: 首页>>代码示例>>Java>>正文


Java XmlMapper.writeValueAsString方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.dataformat.xml.XmlMapper.writeValueAsString方法的典型用法代码示例。如果您正苦于以下问题:Java XmlMapper.writeValueAsString方法的具体用法?Java XmlMapper.writeValueAsString怎么用?Java XmlMapper.writeValueAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.dataformat.xml.XmlMapper的用法示例。


在下文中一共展示了XmlMapper.writeValueAsString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generatePayNativeReplyXML

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public static String generatePayNativeReplyXML(PayPackage payPackage){
	try {
		
		Map<String, String> map = BeanUtils.describe(payPackage);
		map.remove("class");
		
		String sign = Signature.generateSign(map);
		payPackage.setSign(sign);
		
		XmlMapper xmlMapper = new XmlMapper();
		xmlMapper.setSerializationInclusion(Include.NON_EMPTY);
		
		String xmlContent = xmlMapper.writeValueAsString(payPackage);
		
		HttpsRequest httpsRequest = new HttpsRequest();
		String result = httpsRequest.sendPost(Configure.UNIFY_PAY_API, xmlContent);
		return result;
	} catch (Exception e) {
		logger.info("e:" + e);
	}
	
	return null;
}
 
开发者ID:louiseliu,项目名称:weixin-pay,代码行数:24,代码来源:PayUtils.java

示例2: toXML

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
@JsonIgnore
public String toXML() throws JsonProcessingException
{
    XmlMapper xmlMapper = new XmlMapper();
    String xml = xmlMapper.writeValueAsString(this);
    return xml;
}
 
开发者ID:NLeSC,项目名称:escxnat,代码行数:8,代码来源:DataSetConfigList.java

示例3: beanToXml

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public static String beanToXml(Object obj) {
	XmlMapper xml = new XmlMapper();
	try {
		return xml.writeValueAsString(obj);
	} catch (JsonProcessingException e) {
		Logger.getLogger(JacksonXmlUtil.class.getName()).log(Level.SEVERE, null, e);
		return null;
	}
}
 
开发者ID:East196,项目名称:maker,代码行数:10,代码来源:JacksonXmlUtil.java

示例4: main

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
/**
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    List<Test> list = new ArrayList<>();

    Test test = new Test();
    test.setName("doctor");
    Map<String, String> map = new HashMap<>();
    map.put("age", "16");
    map.put("ke", "vv");
    test.setMap(map);
    list.add(test);

    Test test2 = new Test();
    test2.setName("doctor22");
    Map<String, String> map2 = new HashMap<>();
    map2.put("age2", "162");
    map2.put("ke2", "vv2");
    test2.setMap(map2);
    list.add(test2);

    XmlMapper xmlMapper = new XmlMapper();
    String xml = xmlMapper.writeValueAsString(list);
    System.out.println(xml);
    List<Test> ls = xmlMapper.readValue(xml, new TypeReference<List<Test>>() {
    });
    Test t = ls.get(0);
    System.out.println(t);
    System.out.println(t.getName());
    System.out.println(t.getMap());

}
 
开发者ID:sdcuike,项目名称:book-reading,代码行数:35,代码来源:XMLDemo.java

示例5: toXML

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
@Override
public String toXML(T t) {
    String xml = "";
    if (t != null) {
        sessionFactory.getCurrentSession().refresh(t);
        XmlMapper mapper = new XmlMapper();
        try {
            xml = mapper.writeValueAsString(t);
        } catch (JsonProcessingException e) {
            log.warn("Could not serialize to xml", e);
            xml = "";
        }
    }
    return xml;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:BasicSerializableRepository.java

示例6: Test_ById

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
@Test
public void Test_ById() throws Exception
{
	XmlMapper xmlMapper = new XmlMapper();
	for (EdiUser u : edi.querByList())
	{

		String xml = xmlMapper.writeValueAsString(u);
		System.out.println(xml);
		List<Requestorder> r = u.getRequestorders();

		if (r == null)
		{
			System.out.println(11);
		}
		else
		{
			for (Requestorder requestorder : r)
			{
				Item item = requestorder.getItem();
				if (item != null)
				{
					System.out.println(item.getUid());
				}
				else
				{
					System.out.println(111);
				}

				Receiver receiver = requestorder.getReceiver();
				if (receiver != null)
				{
					System.out.println(receiver.getUid());
				}
				else
				{
					System.out.println(111);
				}
				Sender sender = requestorder.getSender();
				if (sender != null)
				{
					System.out.println(sender.getUid());
				}
				else
				{
					System.out.println(1111);
				}
			}
		}

	}
}
 
开发者ID:atliwen,项目名称:EDIOrderPlatform,代码行数:53,代码来源:UserTest.java

示例7: convert_json_to_xml_jackson

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
@Test
public void convert_json_to_xml_jackson () throws IOException {
	
	String browsersAsJson ="[{\"name\":\"Chrome\"},{\"name\":\"FireFox\"},{\"name\":\"Internet Explorer\"}]\n";
	
	ObjectMapper jsonMapper = new ObjectMapper();
    
	@SuppressWarnings("unchecked")
	List<Browser> browsers = jsonMapper.readValue(browsersAsJson, List.class);

    XmlMapper xmlMapper = new XmlMapper();
    
    String browsersAsXml = xmlMapper.writeValueAsString(browsers);
    
    logger.info(browsersAsXml);
    
    assertTrue(browsersAsXml.length() > 0);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:19,代码来源:ConvertJSONtoXML.java

示例8: toXML

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
public String toXML() throws JsonProcessingException
{
    XmlMapper xmlMapper = new XmlMapper();
    String xml = xmlMapper.writeValueAsString(this);
    return xml;
}
 
开发者ID:NLeSC,项目名称:escxnat,代码行数:7,代码来源:XnatToolConfig.java

示例9: convertToXML

import com.fasterxml.jackson.dataformat.xml.XmlMapper; //导入方法依赖的package包/类
/**
 * Convert a JSON string to XML. No direct mapping could be found. So we do a convert
 * to map then use the xmlMapper to convert the Map to XML
 * @param jsonString
 * @return
 * @throws JsonParseException
 * @throws JsonMappingException
 * @throws IOException
 */
public static String convertToXML(String jsonString) throws JsonParseException, JsonMappingException, IOException
{
    XmlMapper xmlMapper = new XmlMapper();
    return xmlMapper.writeValueAsString(JsonUtil.convertToMap(jsonString));
}
 
开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:15,代码来源:JsonUtil.java


注:本文中的com.fasterxml.jackson.dataformat.xml.XmlMapper.writeValueAsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。