-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Steps to reproduce
- Install Magento from
developbranch. - Create custom module with API and respond associative array like below
$response=[];
$response["price_format''] =[
"pattern"=> "$%s",
"precision"=> "2",
"requiredPrecision"=> "2",
"decimalSymbol"=> ".",
"groupSymbol"=> ",",
"groupLength"=> "3",
"integerRequired"=> "1"
];
Expected result
"price_format": {
"pattern": "$%s",
"precision": "2",
"requiredPrecision": "2",
"decimalSymbol": ".",
"groupSymbol": ",",
"groupLength": "3",
"integerRequired": "1"
}
Actual result
"price_format": [
"$%s",
"2",
"2",
".",
",",
"3",
"1"
]
It can be possible by making small change in class Magento\Framework\Reflection\DataObjectProcessor as below, but unsure if it affect to other API SOAP or in core methods etc.
public function buildOutputDataArray($dataObject, $dataObjectType)
{
.
.
.
.
foreach ($value as $elmKey =>$singleValue) {
if (is_object($singleValue) && !($singleValue instanceof Phrase)) {
$singleValue = $this->buildOutputDataArray($singleValue, $arrayElementType);
}
$valueResult[$elmKey] = $this->typeCaster->castValueToType($singleValue, $arrayElementType)
}
.
.
}