<?php
$html =" <span>
123 </span>";
echo json_encode(["content"=>$html]);
$html =" <span>
123 </span>";
echo '{"content":'.json_encode ($html) .'}';
echo json_encode($result, JSON_NUMERIC_CHECK);
$json = '
{
"program_id": "CC1234",
"offerings": [{
"offering_id": "RP445555",
"location_id": "B2222"
}],
"member_id": "10000-01",
"registration_type": "online",
"dry_run": false
}';
$php_array = json_decode($json, true);
var_export($php_array);
array (
'program_id' => 'CC1234',
'offerings' =>
array (
0 =>
array (
'offering_id' => 'RP445555',
'location_id' => 'B2222',
),
),
'member_id' => '10000-01',
'registration_type' => 'online',
'dry_run' => false,
)
SELECT * FROM `action` WHERE `condition` LIKE '%"action": "6"%';
with sqlite3.connect('base.db') as conn:
cursor = conn.cursor()
cursor.execute(f"UPDATE inv SET nabor = json_replace(nabor, '$.id', 99) WHERE ids={ctx.author.id}")
con.commit()
// Parse settings.data into separate variable
let settings_data = JSON.parse(settings.data);
// Update settings_data object by new value
settings_data.methodProperties.CityName="дол";
// Update settings.data by new stringified value
settings.data = JSON.stringify(settings_data);
// Test
alert(JSON.parse(settings.data).methodProperties.CityName);
update `test` set `answer` = '{"test":["qwerty","\\"test\\""]}' ;
Что пробовал:
JSON.stringify. В итоге на выходе получаем строку, вместо объекта. Но как ее теперь закинуть в php файлик?
$json = json_decode($_POST['json']);
SELECT row_to_json(client.*)
FROM (
SELECT
clients.*,
json_agg(
row_to_json(trainers.*)
) trainers
FROM
clients
JOIN trainers ON trainers.t_id < clients.t_id
where
clients.t_id = 10
GROUP BY clients.t_id, clients.t_name, clients.t_phone
) client;
SELECT json_object(
't_id' VALUE client.t_id,
't_name' VALUE client.t_name,
't_phone' VALUE client.t_phone,
't_trainers' VALUE client.trainers
) FROM (
SELECT
clients.*,
json_arrayagg(json_object(
't_id' VALUE trainers.t_id,
't_name' VALUE trainers.t_name,
't_phone' VALUE trainers.t_phone
)) trainers
FROM
clients
JOIN trainers ON trainers.t_id < clients.t_id
where
clients.t_id = 10
GROUP BY clients.t_id, clients.t_name, clients.t_phone
) client;
$data = json_decode($json, true);
$data['group'] = array_reduce(
$data['group'],
function($res, $i) {
$res[$i['id']] = $i['value'];
return $res;
},
[]
);
{"group":{"12":"3","15":"1"}}
<?php
$json = [
[
["id"=>1,
"login"=>'Admin'
],
null,
null,
null,
null,
null
],
'route' => true,
'spectators' => null
];
echo json_encode($json);