Answer the question
In order to leave comments, you need to log in
How to accept json from php and test?
Must accept such data from the server
{
"error":"ok",
"result":{
"amount":"1.00000000",
"address":"YYY",
"txn_id":"XXX",
"confirms_needed":"10",
"timeout":9000,
"status_url":"https:\/\/www.site.net\/index.php?cmd=status&id=XXX&key=ZZZ"
"qrcode_url":"https:\/\/www.site.net\/qrgen.php?id=XXX&key=ZZZ"
}
}
$jsonIterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator(json_decode($json, TRUE)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($jsonIterator as $key => $val) {
if(is_array($val)) {
echo "$key:\n";
} else {
echo "$key => $val\n";
}
}
Answer the question
In order to leave comments, you need to log in
<?php
$json = '{
"error":"ok",
"result":{
"amount":"1.00000000",
"address":"YYY",
"txn_id":"XXX",
"confirms_needed":"10",
"timeout":9000,
"status_url":"https:\/\/www.site.net\/index.php?cmd=status&id=XXX&key=ZZZ",
"qrcode_url":"https:\/\/www.site.net\/qrgen.php?id=XXX&key=ZZZ"
}
}';
$output_std = json_decode($json);
echo $output_std->result->address;
$output_assoc = json_decode($json,true);
echo $output_assoc['result']['address'];
I wrote so many
php, javascript, yii2, drupal, MQL, Android under the nickname
But I didn’t learn how to work with json ... sometimes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question