當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。