欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
XStream
来自开放百科 - 灰狐
(版本间的差异)
小 |
|||
第1行: | 第1行: | ||
{{SeeWikipedia}} | {{SeeWikipedia}} | ||
− | + | XStream是一个开源(BSD) [[Java]]类库,用来将对象序列化成[[XML]]、[[JSON]]或反序列化为对象。 | |
==Features== | ==Features== | ||
第24行: | 第24行: | ||
http://xstream.codehaus.org/ | http://xstream.codehaus.org/ | ||
− | [[ | + | [[category:XML]] |
+ | [[category:JSON]] | ||
+ | [[category:java]] |
2015年1月7日 (三) 13:02的最后版本
您可以在Wikipedia上了解到此条目的英文信息 XStream Thanks, Wikipedia. |
XStream是一个开源(BSD) Java类库,用来将对象序列化成XML、JSON或反序列化为对象。
[编辑] Features
- Ease of use. A high level facade is supplied that simplifies common use cases.
- No mappings required. Most objects can be serialized without need for specifying mappings.
- Performance. Speed and low memory footprint are a crucial part of the design, making it suitable for large object graphs or systems with high message throughput.
- Clean XML. No information is duplicated that can be obtained via reflection. This results in XML that is easier to read for humans and more compact than native Java serialization.
- Requires no modifications to objects. Serializes internal fields, including private and final. Supports non-public and inner classes. Classes are not required to have default constructor.
- Full object graph support. Duplicate references encountered in the object-model will be maintained. Supports circular references.
- Integrates with other XML APIs. By implementing an interface, XStream can serialize directly to/from any tree structure (not just XML).
- Customizable conversion strategies. Strategies can be registered allowing customization of how particular types are represented as XML.
- Error messages. When an exception occurs due to malformed XML, detailed diagnostics are provided to help isolate and fix the problem.
- Alternative output format. The modular design allows other output formats. XStream ships currently with JSON support and morphing.
下面是xml与java对象互转的代码。
Xstream xs = new Xstream(); String xml = xs.toXML(foo); Foo foo = (Foo)xs.FromXML(xml);
XStream也用Jettison做driver,支持Java对象与JSON的序列化
XStream xstream = new XStream(new JettisonMappedXmlDriver());
分享您的观点