imerak 2023-10-01 17:20 采纳率: 0%
浏览 3
已结题

一个查询结果是json,但其中的汉字变成了unicode

前几天刚刚开始学习php,还没有入门,所以遇到的问题都很基础。

我连接mongodb查询:

<?php
header('Content-Type:application/json; charset=utf-8');

// 省略了connect to mongodb

$filter = ['number' => '23097155-1'];

$options = [
    'projection' => ['dqyl' => 0],
    //'sort' => ['zxbh' => -1],
];
$query = new MongoDB\Driver\Query($filter, $options);
$cursor = $manager->executeQuery('table', $query);
foreach ($cursor as $document) {
    $results[]=$document;
}
$jsonData=json_encode($results);

   echo $jsonData;

?>

结果返回了json,但其中的汉字都变成了unicode:

[
    {
        "_id": {
            "$oid": "651612b17399f4534ad78a1d"
        },
        "alias": "db_virtual_library",
        "type": {
            "name": "virtual_library"
        },
        "rkJth": "\u637b\u80a1-7",
        "rksj": "2023-09-29 07:56:33",
        "cksj": "",
        "rkCzg": "\u66f9\u7ea2\u53cb",
        "rkCzgId": "61356321ebf15f684a2bf284",
        "sfhg": "\u5408\u683c",
        "jz": "3.275",
        "llcd": "7012.847965738758",
        "szx": "8",
        "mz": "3.293",
        "dx": "\u5c0f\u5305",
        "zxbh": "23097155",
        "status": "\u672a\u51fa\u5e93",
        "number": "23097155-1",
        "work_plan_id": "5add7124ac151277bfe29a48",
        "gg": "1\u00d73-10.80",
        "fullgg": "1\u00d73-10.80-1860-GB\/T 5224-2014",
        "nx": "\u5de6\u637b",
        "nj": "",
        "qdjb": "1860",
        "bzscr": "2023-09-28",
        "rkxx": "\u81ea\u4ea7",
        "ckxx": "",
        "zlxs": "0.467",
        "sfhgHistoryList": [
            "\u5f85\u68c0",
            "\u5408\u683c"
        ],
        "sfhgHistory": "\u5f85\u68c0\uff0c\u5408\u683c",
        "cj": "\u751f\u4ea7\u4e8c\u90e8",
        "ssbm": "\u751f\u4ea7\u4e8c\u90e8",
        "bz": "\u7532\u73ed",
        "is_data_check": true
    }
]

怎么处理下呢?

我希望查询出这样的:

[
    {
        "_id": {
            "$oid": "651612b17399f4534ad78a1d"
        },
        "alias": "db_virtual_library",
        "type": {
            "name": "virtual_library"
        },
        "rkJth": "捻股-7",
        "rksj": "2023-09-29 07:56:33",
        "cksj": "",
        "rkCzg": "曹红友",
        "rkCzgId": "61356321ebf15f684a2bf284",
        "sfhg": "合格",
        "jz": "3.275",
        "llcd": "7012.847965738758",
        "szx": "8",
        "mz": "3.293",
        "dx": "小包",
        "zxbh": "23097155",
        "status": "未出库",
        "number": "23097155-1",
        "work_plan_id": "5add7124ac151277bfe29a48",
        "gg": "1×3-10.80",
        "fullgg": "1×3-10.80-1860-GB/T 5224-2014",
        "nx": "左捻",
        "nj": "",
        "qdjb": "1860",
        "bzscr": "2023-09-28",
        "rkxx": "自产",
        "ckxx": "",
        "zlxs": "0.467",
        "sfhgHistoryList": [
            "待检",
            "合格"
        ],
        "sfhgHistory": "待检,合格",
        "cj": "生产二部",
        "ssbm": "生产二部",
        "bz": "甲班",
        "is_data_check": true
    }
]
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 10月9日
    • 创建了问题 10月1日