File tree 2 files changed +34
-4
lines changed
lib/internal/Magento/Framework 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -325,19 +325,21 @@ public function convertToXml(
325
325
* Convert object data to JSON
326
326
*
327
327
* @param array $keys array of required keys
328
- * @return string
328
+ * @return bool|string
329
+ * @throws \InvalidArgumentException
329
330
*/
330
331
public function toJson (array $ keys = [])
331
332
{
332
333
$ data = $ this ->toArray ($ keys );
333
- return \Zend_Json:: encode ($ data );
334
+ return \Magento \ Framework \ Serialize \JsonConverter:: convert ($ data );
334
335
}
335
336
336
337
/**
337
338
* The "__" style wrapper for toJson
338
339
*
339
- * @param array $keys
340
- * @return string
340
+ * @param array $keys
341
+ * @return bool|string
342
+ * @throws \InvalidArgumentException
341
343
*/
342
344
public function convertToJson (array $ keys = [])
343
345
{
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Framework \Serialize ;
7
+
8
+ /**
9
+ * This class was introducted only for usage in the \Magento\Framework\DataObject::toJson method.
10
+ * It should not be used in other cases and instead \Magento\Framework\Serialize\Serializer\Json::serialize
11
+ * should be used.
12
+ */
13
+ class JsonConverter
14
+ {
15
+ /**
16
+ * This method should only be used by \Magento\Framework\DataObject::toJson
17
+ * All other cases should use \Magento\Framework\Serialize\Serializer\Json::serialize directly
18
+ *
19
+ * @param string|int|float|bool|array|null $data
20
+ * @return bool|string
21
+ * @throws \InvalidArgumentException
22
+ */
23
+ public static function convert ($ data )
24
+ {
25
+ $ serializer = new \Magento \Framework \Serialize \Serializer \Json ();
26
+ return $ serializer ->serialize ($ data );
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments