I have the result object encode with 'json_encode' PHP like this :
{
output : {
name : 'john',
address : '<city>New York</city><country>United States</country>'
}
}
My expectation is :
{
output : {
name : 'john',
address : {
'city' : 'New York',
'country' : 'United States'
}
}
}
consider $result as response. Below code will give json object
$string = "<?xml version='1.0'?>
<document>".
$result.output.address
."</document>
";
$xml = simplexml_load_string($string);
$json = json_encode($xml);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.