const response = {
"id": "1",
"status": "1",
"name": "Администратор",
"rights": {
"orders.view": "1",
"orders.create": "1",
"orders.changeClosed": "0",
"main.managerList": "1",
"main.workerList": "1",
"finance.reports": "1",
"compendiums.counteragents": "1",
"compendiums.works": "1"
},
"error": {
"error_code": 0
}
};
const roleData = {
checkRights: []
};
const rights = Object.keys(response.rights).filter((key) => +response.rights[key] === 1);
roleData.checkRights = roleData.checkRights.concat(rights);
console.log(roleData);
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
$url= 'https://www.mos.ru/altmosmvc/api/v1/taxi/getInfo/?Region=Москва&RegNum=&FullName=&LicenseNum=&Condition=&pagenumber=1';
$client = new Client([
'base_url' => $url,
'cookies' => CookieJar::fromArray(['mos_id' => 'CllGx1yOW5nBYizxkxtbAgA='], '.mos.ru'),
'allow_redirects' => true,
'decode_content' => true
]);
$response = $client->request('get', $url);
echo $response->getBody()->getContents();
:class="className"
. Ну и документацию почитайте. .done(function( answer ) {
var data = JSON.parse(answer[0]);
console.log(answer[0].result)
console.log(data['result']);
console.log(data.result);
})
.done(function( answer ) {
if (!(!!!answer || !!!answer.length || answer.length <=0))
return;
for(let i=0; i<answer.length, i++)
{
var data = JSON.parse(answer[i]);
console.log(answer[i].result)
console.log(data['result']);
console.log(data.result);
}
})