Xstream learning materials, xstream Learning
For xml operations in java, Xstream is the first in our project. The reason is not mentioned. Follow the footsteps of the masses. The Xstream documentation is as follows.
Among them, 2, 3, and 4 are good blog posts written on the Internet. The example shows how to use it
First, Brief introductionXStream is an open source framework developed by ThoughtWorks for the transformation of XML data into Java objects and JSON data. It does not require schema or other mapping files to be able to convert between Java objects and XML files, API calls are very convenient, and the extension is powerful.1 , XStream the characteristicsA) flexible and easy-to-use: Provides a simple, flexible, easy-to-use unified interface at a higher
SpringMVC integrates xStream and springmvcxstream
I. Introduction:
XStream can easily convert Java objects into xml and JSON objects. This blog will use springMVC to integrate and use xStream to convert xml.
Blog about xStream use: http://blog.csdn.net/zdp072/article/details/39054197
Ii. Example:
1. code structure:
2
Xml,object,json An analysis of transformation Xstream the UsePlease respect other people's labor results, reproduced please specify the source: Analysis of the Xml,object,json conversion XStream useXStream is a simple library that is used primarily for Java objects, and XML conversion between the. However , XStream also has built-in support for Json . features
Simplified API; non- ing file; high performance, low memory usage; neat XML; no need to modify objects, support for internal private fields; no need for settergetter method, final field; provide serialization interface; custom conversion type policy; detailed error diagnosis;
Features
Simplified API;
No ing file;
High performance, low memory usage;
Neat XML;
Objects do not need to be modified. internal private fields are supported;
The setter/getter method and final field are not required
[053] public platform development tutorial Article 23rd-SAE does not support XStream framework solutions,-saexstream
Problem description
In the last few days (after December August 20, 2014), many netizens suddenly responded that the public platform development code in Liu Feng's blog reported an error on SAES, or the code could be deployed normally, but the message sent to the public account did not respond. In the past, some beginners have questione
II. important annotations @ XStreamAlias alias @ XStreamAsAttribute is defined as attribute @ XStreamOmitField ignore @ XStreamConverter processing date format @ XStreamImplicit (itemFieldName quot; roles quot ;) process List 1. import jar packages
com.thoughtworks.xstream
xstream
1.4.8
II. Important Notes
@ XStreamAlias defines the alias
@ XStreamAsAttribute is defined as an attribute.
@ XStreamOmitField ignore
@ XStreamConve
Recently made WebService message conversion of the public interface to use the Xsream tool Library, write a small summary memo ...XStream is a Java class library that can convert JavaBean and XML bidirectional, based on the xstream-1.4.4 version of this article. The required maven dependencies are as follows:1. Basic Use MethodNew Xstream (). ToXML (Bean);The XML
Prepare two beans first
1 public class book {2 Private int bookid; 3 private string bookname; 4 private string bookcode; 5 6... (The get and set methods are omitted) 7}
Public class bookshelf {private int number; private list
Use
1 book book1 = New Book (); 2 book1.setbookcode ("001"); 3 book1.setbookid (1); 4 book1.setbookname ("Java programming "); 5 book book2 = New Book (); 6 book2.setbookcode ("002"); 7 book2.setbookid (2); 8 book2.setbookname ("JSP programming "); 9 bookshelf = new books
The previous article referred to the use of Java native serialization to represent an object. Summarize the pros and cons of this method of object representation:1, Pure Java environment in this way can work well, because it comes with Java, and does not require third-party jar package support2. In a multi-lingual environment, it is difficult to restore results in other languages after storing in a Java serialization format3, occupies a large number of bytes, and serialization, deserialization e
In java, XStream is used to convert an object to an xml string or convert an xml string to an object =
We often have requirements, such as calling others' interfaces, and others will return data in json or xml format to you. Then we need to convert the data into corresponding objects for our own use;Sometimes someone else calls our interface to provide data in xml or json format. If json is not mentioned here, it is easy to process, springMvc is easy
Reprint Source: http://hwy584624785.iteye.com/blog/1168680This example uses XStream to generate an XML file and then to serialize the contents of the XML file.XStream is a simple class library that can serialize objects to XML, and can also restore XML to an object.XStream Official website: http://xstream.codehaus.org/The attachment provides XStream and XPP3 related jar downloads:Xstream-1.2.2.jarXpp3-1.1.3
Original address: http://www.cnblogs.com/hoojo/archive/2011/04/22/2025197.html
XStream Frame
XStream can easily convert Java objects and XML documents to each other, and can modify a particular attribute and node name, and also support the conversion of JSON;
There is an introduction to json-lib this framework, online blog: http://www.cnblogs.com/hoojo/archive/2011/04/21/2023805.html
And the Jackson Framewo
The project needs to be translated. It is simple and convenient.
Http://xstream.codehaus.org/tutorial.html
Two minute tutorial
This is a very quick introduction to xstream. skim read it to get an idea of how simple it is to convert objects to XML and back again. i'm sure you'll have questions afterwards.Create classes to be serialized
Here's a couple of simple classes. xstream can convert instances of t
Nine, The persistence ofIn the example in section eighth, when we manipulate a set of objects, we can specify writer, outputstream to write out the serialized XML data, and we can also specify reader, InputStream to read the serialized XML data. We need to specify the input and output stream when we need to write and read the file, and we need to explicitly call the input and output method to implement the serialization and deserialization of the Java object, in fact, we can make the Java object
XML and JSON are two commonly used formats for data description and transmission today, especially when it comes to JS using JSON quite frequently. Naturally, in the Java world, it is the XStream and json-lib that are the components that JavaBean and the two formats convert to each other. Here I jot down the usage of xstream.
In fact, similar tools have already existed. If you have used DWR comrades, there
Original address: http://www.cnblogs.com/hoojo/archive/2011/04/22/2025197.html
XStream Framework
XStream can easily convert Java objects and XML documents to each other, and can modify a particular attribute and node name, and also support JSON conversion;
Previous Json-lib this framework, online blog: http://www.cnblogs.com/hoojo/archive/2011/04/21/2023805.html
And Jackson this framework, online blog: http
Android XMl parsing magic xstream 6: converting the set list into XML documents, androidxstream
For more information about xstream, see:
Android XMl parsing magic xstream 1: parse the aa. xml file in the asset folder of the android Project
Android XMl parsing magic xstream 2: Converting objects into xml
Android XMl par
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.