mirror of
https://codeberg.org/icewind/php-literal-parser.git
synced 2026-06-03 10:34:08 +02:00
handle empty arrays and trailing commas
This commit is contained in:
parent
4c4cbefcf5
commit
36b75790f0
4 changed files with 51 additions and 21 deletions
23
examples/parse.rs
Normal file
23
examples/parse.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use php_object_parser::parse;
|
||||
|
||||
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,
|
||||
)
|
||||
"###;
|
||||
|
||||
match parse(source) {
|
||||
Ok(result) => print!("{:#?}", result),
|
||||
Err(err) => eprint!("{}", err),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue