0

I am getting this response in magento 2 curl. Do you know, how we can convert this response into array?

Here is my code:

$this->curlClient->post($url, $post);
$responseCurl = $this->curlClient->getBody();
print_r($responseCurl);

Current O/P:

{"status":true,"data":{"name":null,"start":"2018-04-19 11:07:02","end":"2018-04-19 11:07:02","discount_type":"P","discount_amount":12,"code":"abc_123"}}

Thanks in advance?

Pankaj Sharma
  • 1,381
  • 2
  • 20
  • 40

1 Answers1

0

Try json_decode:

 $this->curlClient->post($url, $post);
$responseCurl = $this->curlClient->getBody();
$data = json_decode($responseCurl, TRUE);
print_r($data);

The second parameter will make json string into an associative arrays.

Arunendra
  • 7,446
  • 3
  • 29
  • 54