Magento 2: convert curl response into arrayMagento 2 curl send header with responseupdate cURL php5 moduleDifference between adapter curl and client curl in magento 2Unable to create customer using curl commandHow to get an array from curl responsecURL with Magento 2Unable to add product into cart from third party CURLMagento 2 : CURL Use in ObserverMagento 2: CURL response into arrayMagento 1.9.2.4 cURL issue
New order #4: World
Why doesn't a const reference extend the life of a temporary object passed via a function?
Could Giant Ground Sloths have been a good pack animal for the ancient Mayans?
Why is my log file so massive? 22gb. I am running log backups
A poker game description that does not feel gimmicky
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
How to deal with fear of taking dependencies
Patience, young "Padovan"
What happens when a metallic dragon and a chromatic dragon mate?
Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?
Extreme, but not acceptable situation and I can't start the work tomorrow morning
Are white and non-white police officers equally likely to kill black suspects?
Copycat chess is back
Hosting Wordpress in a EC2 Load Balanced Instance
Calculate Levenshtein distance between two strings in Python
Crop image to path created in TikZ?
Prime joint compound before latex paint?
Why do UK politicians seemingly ignore opinion polls on Brexit?
Where else does the Shulchan Aruch quote an authority by name?
What is the meaning of "of trouble" in the following sentence?
Symmetry in quantum mechanics
LWC and complex parameters
extract characters between two commas?
Does it makes sense to buy a new cycle to learn riding?
Magento 2: convert curl response into array
Magento 2 curl send header with responseupdate cURL php5 moduleDifference between adapter curl and client curl in magento 2Unable to create customer using curl commandHow to get an array from curl responsecURL with Magento 2Unable to add product into cart from third party CURLMagento 2 : CURL Use in ObserverMagento 2: CURL response into arrayMagento 1.9.2.4 cURL issue
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am not able to convert magento 2 JSON response into array. Can you please help in short out this problem?
Here is my code:
$url = 'http://example.com/api/coop';
$post = [
'firstname' => $userDetail->firstname,
'lastname' => $userDetail->lastname,
'email' => $userDetail->email,
'password' => $userDetail->password
];
$this->curlClient->post($url, $post);
$responseCurl = $this->curlClient->getBody();
print_r($responseCurl);
die();
Output:
"coop_id":"COOP33"
I have to use coop_id
value somewhere in my logic. Thanks in advance.
magento-2.1.3 curl
add a comment |
I am not able to convert magento 2 JSON response into array. Can you please help in short out this problem?
Here is my code:
$url = 'http://example.com/api/coop';
$post = [
'firstname' => $userDetail->firstname,
'lastname' => $userDetail->lastname,
'email' => $userDetail->email,
'password' => $userDetail->password
];
$this->curlClient->post($url, $post);
$responseCurl = $this->curlClient->getBody();
print_r($responseCurl);
die();
Output:
"coop_id":"COOP33"
I have to use coop_id
value somewhere in my logic. Thanks in advance.
magento-2.1.3 curl
add a comment |
I am not able to convert magento 2 JSON response into array. Can you please help in short out this problem?
Here is my code:
$url = 'http://example.com/api/coop';
$post = [
'firstname' => $userDetail->firstname,
'lastname' => $userDetail->lastname,
'email' => $userDetail->email,
'password' => $userDetail->password
];
$this->curlClient->post($url, $post);
$responseCurl = $this->curlClient->getBody();
print_r($responseCurl);
die();
Output:
"coop_id":"COOP33"
I have to use coop_id
value somewhere in my logic. Thanks in advance.
magento-2.1.3 curl
I am not able to convert magento 2 JSON response into array. Can you please help in short out this problem?
Here is my code:
$url = 'http://example.com/api/coop';
$post = [
'firstname' => $userDetail->firstname,
'lastname' => $userDetail->lastname,
'email' => $userDetail->email,
'password' => $userDetail->password
];
$this->curlClient->post($url, $post);
$responseCurl = $this->curlClient->getBody();
print_r($responseCurl);
die();
Output:
"coop_id":"COOP33"
I have to use coop_id
value somewhere in my logic. Thanks in advance.
magento-2.1.3 curl
magento-2.1.3 curl
asked Apr 24 '18 at 7:59
Pankaj SharmaPankaj Sharma
5781623
5781623
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You can check in PHP sandbox, example below.
Show example
<?php
$jsonString = '"coop_id":"COOP33"';
$stdClass = json_decode($jsonString);
echo $stdClass->coop_id; //COOP33
$array = json_decode($jsonString, true);
echo $array['coop_id']; //COOP33
add a comment |
$json = '"a":1,"b":2,"c":3,"d":4,"e":5';
var_dump(json_decode($json)); // Object
var_dump(json_decode($json, true)); // Associative array
add a comment |
You can use json_decode as follows.
<?php
$json = $responseCurl;
$array = json_decode($json, true);
$coop_id = $array['coop_id'];
?>
Thanks for reply soon! But its not working for me.
– Pankaj Sharma
Apr 24 '18 at 8:29
use var_dump(json_decode($json, true)); to see your values.
– Pallavi
Apr 24 '18 at 8:39
@PankajSharma Did you assign response to $json variable ?
– Kishan Patadia
Apr 24 '18 at 8:47
@KishanPatadia I am sending curl response in JSON format.
– Pankaj Sharma
Apr 24 '18 at 9:41
@PankajSharma Please try updated answer code
– Kishan Patadia
Apr 24 '18 at 10:35
|
show 1 more comment
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f223427%2fmagento-2-convert-curl-response-into-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can check in PHP sandbox, example below.
Show example
<?php
$jsonString = '"coop_id":"COOP33"';
$stdClass = json_decode($jsonString);
echo $stdClass->coop_id; //COOP33
$array = json_decode($jsonString, true);
echo $array['coop_id']; //COOP33
add a comment |
You can check in PHP sandbox, example below.
Show example
<?php
$jsonString = '"coop_id":"COOP33"';
$stdClass = json_decode($jsonString);
echo $stdClass->coop_id; //COOP33
$array = json_decode($jsonString, true);
echo $array['coop_id']; //COOP33
add a comment |
You can check in PHP sandbox, example below.
Show example
<?php
$jsonString = '"coop_id":"COOP33"';
$stdClass = json_decode($jsonString);
echo $stdClass->coop_id; //COOP33
$array = json_decode($jsonString, true);
echo $array['coop_id']; //COOP33
You can check in PHP sandbox, example below.
Show example
<?php
$jsonString = '"coop_id":"COOP33"';
$stdClass = json_decode($jsonString);
echo $stdClass->coop_id; //COOP33
$array = json_decode($jsonString, true);
echo $array['coop_id']; //COOP33
answered Apr 5 at 9:43
bdnbdn
213
213
add a comment |
add a comment |
$json = '"a":1,"b":2,"c":3,"d":4,"e":5';
var_dump(json_decode($json)); // Object
var_dump(json_decode($json, true)); // Associative array
add a comment |
$json = '"a":1,"b":2,"c":3,"d":4,"e":5';
var_dump(json_decode($json)); // Object
var_dump(json_decode($json, true)); // Associative array
add a comment |
$json = '"a":1,"b":2,"c":3,"d":4,"e":5';
var_dump(json_decode($json)); // Object
var_dump(json_decode($json, true)); // Associative array
$json = '"a":1,"b":2,"c":3,"d":4,"e":5';
var_dump(json_decode($json)); // Object
var_dump(json_decode($json, true)); // Associative array
answered Apr 24 '18 at 8:41
PallaviPallavi
30918
30918
add a comment |
add a comment |
You can use json_decode as follows.
<?php
$json = $responseCurl;
$array = json_decode($json, true);
$coop_id = $array['coop_id'];
?>
Thanks for reply soon! But its not working for me.
– Pankaj Sharma
Apr 24 '18 at 8:29
use var_dump(json_decode($json, true)); to see your values.
– Pallavi
Apr 24 '18 at 8:39
@PankajSharma Did you assign response to $json variable ?
– Kishan Patadia
Apr 24 '18 at 8:47
@KishanPatadia I am sending curl response in JSON format.
– Pankaj Sharma
Apr 24 '18 at 9:41
@PankajSharma Please try updated answer code
– Kishan Patadia
Apr 24 '18 at 10:35
|
show 1 more comment
You can use json_decode as follows.
<?php
$json = $responseCurl;
$array = json_decode($json, true);
$coop_id = $array['coop_id'];
?>
Thanks for reply soon! But its not working for me.
– Pankaj Sharma
Apr 24 '18 at 8:29
use var_dump(json_decode($json, true)); to see your values.
– Pallavi
Apr 24 '18 at 8:39
@PankajSharma Did you assign response to $json variable ?
– Kishan Patadia
Apr 24 '18 at 8:47
@KishanPatadia I am sending curl response in JSON format.
– Pankaj Sharma
Apr 24 '18 at 9:41
@PankajSharma Please try updated answer code
– Kishan Patadia
Apr 24 '18 at 10:35
|
show 1 more comment
You can use json_decode as follows.
<?php
$json = $responseCurl;
$array = json_decode($json, true);
$coop_id = $array['coop_id'];
?>
You can use json_decode as follows.
<?php
$json = $responseCurl;
$array = json_decode($json, true);
$coop_id = $array['coop_id'];
?>
edited Apr 24 '18 at 10:35
answered Apr 24 '18 at 8:06
Kishan PatadiaKishan Patadia
3,8451925
3,8451925
Thanks for reply soon! But its not working for me.
– Pankaj Sharma
Apr 24 '18 at 8:29
use var_dump(json_decode($json, true)); to see your values.
– Pallavi
Apr 24 '18 at 8:39
@PankajSharma Did you assign response to $json variable ?
– Kishan Patadia
Apr 24 '18 at 8:47
@KishanPatadia I am sending curl response in JSON format.
– Pankaj Sharma
Apr 24 '18 at 9:41
@PankajSharma Please try updated answer code
– Kishan Patadia
Apr 24 '18 at 10:35
|
show 1 more comment
Thanks for reply soon! But its not working for me.
– Pankaj Sharma
Apr 24 '18 at 8:29
use var_dump(json_decode($json, true)); to see your values.
– Pallavi
Apr 24 '18 at 8:39
@PankajSharma Did you assign response to $json variable ?
– Kishan Patadia
Apr 24 '18 at 8:47
@KishanPatadia I am sending curl response in JSON format.
– Pankaj Sharma
Apr 24 '18 at 9:41
@PankajSharma Please try updated answer code
– Kishan Patadia
Apr 24 '18 at 10:35
Thanks for reply soon! But its not working for me.
– Pankaj Sharma
Apr 24 '18 at 8:29
Thanks for reply soon! But its not working for me.
– Pankaj Sharma
Apr 24 '18 at 8:29
use var_dump(json_decode($json, true)); to see your values.
– Pallavi
Apr 24 '18 at 8:39
use var_dump(json_decode($json, true)); to see your values.
– Pallavi
Apr 24 '18 at 8:39
@PankajSharma Did you assign response to $json variable ?
– Kishan Patadia
Apr 24 '18 at 8:47
@PankajSharma Did you assign response to $json variable ?
– Kishan Patadia
Apr 24 '18 at 8:47
@KishanPatadia I am sending curl response in JSON format.
– Pankaj Sharma
Apr 24 '18 at 9:41
@KishanPatadia I am sending curl response in JSON format.
– Pankaj Sharma
Apr 24 '18 at 9:41
@PankajSharma Please try updated answer code
– Kishan Patadia
Apr 24 '18 at 10:35
@PankajSharma Please try updated answer code
– Kishan Patadia
Apr 24 '18 at 10:35
|
show 1 more comment
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f223427%2fmagento-2-convert-curl-response-into-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown