gpt4 book ai didi

php - 需要从 json 值中删除反斜杠

转载 作者:行者123 更新时间:2023-12-04 18:20:03 24 4
gpt4 key购买 nike

我需要从 codeigniter 中删除 \,这是我的输出:

{
"id": "3496",
"label": "B\\'less S\\'On Chicken Leg 200-240g",
"sku": "",
"cat_id": "72",
"slug": "b-less-s-on-chicken-leg-200-240g",
"product_min_order_qty": "1",
"product_unit_type": "pkt",
"alter_unit_type": "",
"product_short_desc": null,
"product_long_desc": "B\\'less S\\'On Chicken Leg 200-240g\r\n\r\n8 X 2kg / ctn",
"image": null
}

下面是我的代码:

$product_res = $this->Mydb->get_all_records('*', 'table_name');
$responseData = array("status" => 'ok',"categories" => $category_res,"products" => $product_res,"search_count" => $search_count, "Response" => array("response" => "Success", "response_code" => 1));
$this->output->set_content_type('application/json;');
$this->output->set_header('Access-Control-Allow-Origin: *');
return $this->output->set_output(json_encode($responseData,JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));

最佳答案

只需使用 stripslashes功能

return $this->output->set_output(stripslashes(json_encode($responseData,JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)));

关于php - 需要从 json 值中删除反斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46110831/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com