PHP 把字符串 转为json
<?php
$jsonString = '{"message":"Hello, World!"}';
$jsonObject = json_decode($jsonString);
// 修改JSON对象
$jsonObject->message = "Goodbye, World!";
// 将修改后的对象转换回JSON字符串
$newJsonString = json_encode($jsonObject);
echo $newJsonString; // 输出: {"message":"Goodbye, World!"}
?>
<?php
$string = "He said, \"Hello, World!\"";
$json = json_encode(array("message" => $string));
echo $json; // 输出: {"message":"He said, \"Hello, World!\""}
?>




