I have a JSON file like this:
test.json
{
"barcode": {
"message": "<?xml version=\"1.0\" encoding = \"utf-8?\"><PrintLetterBarcodeData name=\"ABCD \" gender=\"FEMALE\" yob=\"1964\"/>",
"format": "PKBarcodeFormatQR",
"messageEncoding": "iso-8859-1"
}
}
and a PHP file like this:
test.php
<?php
$JSON = file_get_contents('test.json');
$json_object = json_decode($JSON);
print_r($json_object);
?>
I am trying to read the value for the key "message" under "barcode". I am getting an empty string. Here's what I get when I print the object.
stdClass Object ( [barcode] => stdClass Object ( [message] => [format] => PKBarcodeFormatQR [messageEncoding] => iso-8859-1 ) )
JSON is good, message has XML content. I need to get read that XML content in PHP. Please let me know how I can do that?