mirror of
https://codeberg.org/icewind/php-literal-parser.git
synced 2026-06-03 18:44:07 +02:00
serde example
This commit is contained in:
parent
cf2fda0c8c
commit
0090bea796
2 changed files with 21 additions and 0 deletions
24
examples/value.rs
Normal file
24
examples/value.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use php_literal_parser::{from_str, Value};
|
||||
|
||||
fn main() {
|
||||
let source = r###"
|
||||
array (
|
||||
"double" => "quote",
|
||||
'single' => 'quote',
|
||||
"escaped" => "\"quote\"",
|
||||
1 => 2,
|
||||
"nested" => [
|
||||
"sub" => "key",
|
||||
],
|
||||
"array" => [1,2,3,4],
|
||||
"bool" => false,
|
||||
"negative" => -1,
|
||||
"null" => null,
|
||||
)
|
||||
"###;
|
||||
|
||||
match from_str::<Value>(source) {
|
||||
Ok(result) => print!("{:#?}", result),
|
||||
Err(err) => eprint!("{}", err.with_source(source)),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue