Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data.php
Go to the documentation of this file.
1 <?php
7 
14 {
18  protected $jsonDecoder;
19 
23  protected $jsonEncoder;
24 
30  public function __construct(
31  \Magento\Framework\App\Helper\Context $context,
34  ) {
35  parent::__construct($context);
36  $this->jsonDecoder = $jsonDecoder;
37  $this->jsonEncoder = $jsonEncoder;
38  }
39 
46  public function jsonEncode($valueToEncode)
47  {
48  return $this->jsonEncoder->encode($valueToEncode);
49  }
50 
58  public function jsonDecode($encodedValue)
59  {
60  return $this->jsonDecoder->decode($encodedValue);
61  }
62 }
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Json\DecoderInterface $jsonDecoder, \Magento\Framework\Json\EncoderInterface $jsonEncoder)
Definition: Data.php:30
jsonEncode($valueToEncode)
Definition: Data.php:46