You can't transport Objects or serialize Classes, json_* replace it bei stdClass!
<?php
$dom = new DomDocument( '1.0', 'utf-8' );
$body = $dom->appendChild( $dom->createElement( "body" ) );
$body->appendChild( $dom->createElement( "forward", "Hallo" ) );
$JSON_STRING = json_encode(
array(
"aArray" => range( "a", "z" ),
"bArray" => range( 1, 50 ),
"cArray" => range( 1, 50, 5 ),
"String" => "Value",
"stdClass" => $dom,
"XML" => $dom->saveXML()
)
);
unset( $dom );
$Search = "XML";
$MyStdClass = json_decode( $JSON_STRING );
try {
throw new Exception( "$Search isn't a Instance of 'stdClass' Class by json_decode()." );
if ( $MyStdClass->$Search instanceof $MyStdClass )
var_dump( "<pre>instanceof:" , $MyStdClass->$Search , "</pre>" );
} catch( Exception $ErrorHandle ) {
echo $ErrorHandle->getMessage();
if ( property_exists( $MyStdClass, $Search ) ) {
$dom = new DomDocument( "1.0", "utf-8" );
$dom->loadXML( $MyStdClass->$Search );
$body = $dom->getElementsByTagName( "body" )->item(0);
$body->appendChild( $dom->createElement( "rewind", "Nice" ) );
var_dump( htmlentities( $dom->saveXML(), ENT_QUOTES, 'utf-8' ) );
}
}
?>