File tree 2 files changed +31
-4
lines changed
lib/internal/Magento/Framework 2 files changed +31
-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
+ * Used to convert \Magento\Framework\DataObject to Json
10
+ *
11
+ * @deprecated @see \Magento\Framework\Serialize\Serializer\Json::serialize
12
+ */
13
+ class JsonConverter
14
+ {
15
+ /**
16
+ * @param $data
17
+ * @return bool|string
18
+ * @throws \InvalidArgumentException
19
+ */
20
+ public static function convert ($ data )
21
+ {
22
+ $ serializer = new \Magento \Framework \Serialize \Serializer \Json ();
23
+ return $ serializer ->serialize ($ data );
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments