Comments (2)
I hope that this time whole text will be visible..
#[macro_use]
extern crate serde_derive;
extern crate serde_xml_rs;
//extern crate serde;
use serde_xml_rs::*;
#[derive(Debug, Deserialize, Serialize) ]
struct Item {
pub name: String,
pub source: String
}
#[derive(Debug, Deserialize, Serialize)]
struct Project {
pub name: String,
#[serde(rename = "Item", default)]
pub items: Vec<Item>
}
fn get_project() -> Project {
let s = r##"
"##;
let project: Project = deserialize(s.as_bytes()).unwrap();
project
}
fn main() {
let p: Project = get_project();
println!("\n\ndeserialized\n{:#?}", p);
let mut buffer = Vec::new();
serialize(&p, &mut buffer);
println!("\nserialized buffer:\n{:?}", buffer);
let serialized = String::from_utf8(buffer).unwrap();
println!("\nserialized:\n{}", serialized);
}
deserialized
Project {
name: "my_project",
items: [
Item {
name: "hello",
source: "world.rs"
},
Item {
name: "goodbye",
source: "world.rs"
}
]
}
serialized buffer:
[60, 80, 114, 111, 106, 101, 99, 116, 62, 60, 110, 97, 109, 101, 62, 109, 121, 95, 112, 114, 111, 106, 101, 99, 116, 60, 47, 110, 97, 109, 101, 62, 60, 73, 116, 101, 109, 62]
serialized:
my_project
from serde-xml-rs.
Please use ```rust
and ```
lines to wrap your code blocks, then it would be much easier to read them.
from serde-xml-rs.
Related Issues (20)
- Custom { field: "missing field `soap:Body`" } when colon used
- LastElementNameNotAvailable error on writing HOT 11
- Decoding 0 elements in to a Vec gives "custom: missing field `$value`" error HOT 2
- Deserialization with custom deserializer does not work according to serde spec HOT 1
- Is there something like "from_slice"
- custom: missing field `id`
- Expose EmitterConfig/Make document declaration optional
- readme.md example broken out of the box
- readme.md example broken out of the box
- Can't serialize a struct with error 'LastElementNotAvailable'
- Error `DocumentStartAlreadyEmitted` while trying to serialize simple structure in 0.6.0
- Hoot serialize into attributes HOT 2
- Cannot add attribute id
- duplicate field `$value`'
- Does anyone have an improved fork or does any better alternative exist?
- You've found a bug in xml-rs, caused by calls to push_pos() in states that don't end up emitting events
- Regression : Fix xml-rs depencency version in Cargo.toml
- error order when serde a enum field
- Parse error whlist parsing hackernoon xml feed
- Enum/choice list does not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serde-xml-rs.