Open
Description
So apparently, and please forgive me as Ruby is still kind of lost on me, I'm forced to unserialize a previously PHP serialized data structure, which uses "stdClass" as an object, in this exact string:
O:8:"stdClass":1:{s:7:"Results";a:1:{i:0;O:8:"stdClass":2:{s:2:"Id";i:54;s:4:"Name";s:14:"This is a Name";}}}
which when I use PHPSerializer.load()
on this data, I get:
unserializer.y:38:in `new': identifier stdClass needs to be constant (NameError)
from unserializer.y:38:in `_reduce_13'
from /var/lib/gems/1.9.1/gems/php-serialization-0.5.3/lib/php_serialization/tokenizer.rb:12:in `each'
from /var/lib/gems/1.9.1/gems/racc-1.4.12/lib/racc/parser.rb:331:in `_racc_yyparse_c'
from /var/lib/gems/1.9.1/gems/racc-1.4.12/lib/racc/parser.rb:331:in `yyparse'
from unserializer.y:75:in `run'
from /var/lib/gems/1.9.1/gems/php-serialization-0.5.3/lib/php_serialization.rb:16:in `load'
from ser.rb:15:in `<main>'
From the looks of things here, it's because the Object name here stdClass
, starts with a lower case letter. Which after a few hours of raw frustration (as a Ruby limitation of Structs I wasn't aware of) I finalyl deduced by instead calling it "StdClass" , which get's me:
unserializer.y:38: warning: redefining constant Struct::StdClass
#<struct Struct::StdClass Results={0=>#<struct Struct::StdClass Id=54, Name="This is a Name">}>
For now, I'm just going to have a run a string conversion to make sure all first letters are capitalized, as I am dealing with a situation where I cannot change the underlying data itself.
Metadata
Metadata
Assignees
Labels
No labels