You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

向JSON列插入数据时遇Unexpected end of JSON input错误求助

解决JSON列插入{}触发"Unexpected end of JSON input"错误的方法

从你提供的报错栈和界面来看,这是phpMyAdmin 5.2.1deb1+focal2版本的前端JavaScript bug:在单元格编辑保存时,前端代码尝试解析一个不完整的JSON字符串,导致JSON.parse抛出异常。以下是几种解决办法:

1. 直接用SQL语句操作(最可靠)

避开前端的编辑验证逻辑,直接执行SQL插入/更新:

-- 插入空JSON对象
INSERT INTO 你的表名 (json列名) VALUES ('{}');

-- 更新现有行的JSON列
UPDATE 你的表名 SET json列名 = '{}' WHERE 条件;

2. 临时绕过前端bug

如果一定要用单元格编辑功能:

  • 先输入一个非空的合法JSON,比如{"temp": "value"},保存成功后再编辑为{};
  • 或者尝试输入[](空数组),部分场景下空数组的处理逻辑没有问题,之后再修改为{}。

3. 升级phpMyAdmin版本

这个空JSON对象编辑报错的问题在phpMyAdmin的后续版本(如5.2.2及以上)中已经被修复,升级到最新稳定版本即可彻底解决该问题。


报错详情

{
    "pma_version": "5.2.1deb1+focal2",
    "browser_name": "CHROME",
    "browser_version": "135.0.0.0",
    "user_os": "Win",
    "server_software": "Apache/2.4.63 (Ubuntu)",
    "user_agent_string": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
    "locale": "ru",
    "configuration_storage": "enabled",
    "php_version": "8.3.19",
    "script_name": "index.php",
    "exception_type": "js",
    "exception": {
        "mode": "stack",
        "name": "SyntaxError",
        "message": "Unexpected end of JSON input",
        "stack": [
            {
                "line": "342",
                "func": "",
                "context": [
                    "            if (lastException === ex) {",
                    "                processLastException();",
                    "            }",
                    "        }, (stack.incomplete ? 2000 : 0));",
                    "",
                    "        throw ex; // re-throw to propagate to the top level (and cause wind//...",
                    "    }",
                    "",
                    "    report.subscribe = subscribe;",
                    "    report.unsubscribe = unsubscribe;",
                    "    return report;"
                ],
                "uri": "js/vendor/tracekit.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/vendor/tracekit.js"
            },
            {
                "func": "JSON.parse",
                "line": "",
                "column": "",
                "context": "",
                "uri": "index.php?",
                "scriptname": "index.php"
            },
            {
                "func": "Object.saveEditedCell",
                "line": "1452",
                "column": "63",
                "context": [
                    "        let isValueUpdated;",
                    "        if ($thisField.attr('data-type') !== 'json') {",
                    "          isValueUpdated = thisFieldParams[fieldName] !== Functions.getCell//...",
                    "        } else {",
                    "          const JSONString = Functions.stringifyJSON(thisFieldParams[fieldN//...",
                    "          isValueUpdated = JSONString !== JSON.stringify(JSON.parse(Functio//...",
                    "        }",
                    "        if (g.wasEditedCellNull || isValueUpdated) {",
                    "          needToPost = true;",
                    "        }",
                    "      }"
                ],
                "uri": "js/dist/makegrid.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/dist/makegrid.js"
            },
            {
                "func": "Object.saveOrPostEditedCell",
                "line": "1474",
                "column": "21",
                "context": [
                    "     *",
                    "     * @param options Optional, this object contains a boolean named move (//...",
                    "     *                and a <td> to which the grid_edit should move",
                    "     */",
                    "    saveOrPostEditedCell: function (options) {",
                    "      var saved = g.saveEditedCell();",
                    "      // Check if $cfg['SaveCellsAtOnce'] is false",
                    "      if (!g.saveCellsAtOnce) {",
                    "        // Check if need_to_post is true",
                    "        if (saved) {",
                    "          // Check if this function called from 'move' functions"
                ],
                "uri": "js/dist/makegrid.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/dist/makegrid.js"
            },
            {
                "func": "Object.hideEditCell",
                "line": "635",
                "column": "13",
                "context": [
                    "      if (g.isCellEditActive && !force) {",
                    "        // cell is being edited, save or post the edited data",
                    "        if (options !== undefined) {",
                    "          g.saveOrPostEditedCell(options);",
                    "        } else {",
                    "          g.saveOrPostEditedCell();",
                    "        }",
                    "        return;",
                    "      }",
                    "",
                    "      // cancel any previous request"
                ],
                "uri": "js/dist/makegrid.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/dist/makegrid.js"
            },
            {
                "func": "HTMLHtmlElement.<anonymous>",
                "line": "2032",
                "column": "13",
                "context": [
                    "        }",
                    "      });",
                    "      $('html').on('click', function (e) {",
                    "        // hide edit cell if the click is not fromDat edit area",
                    "        if ($(e.target).parents().index($(g.cEdit)) === -1 && !$(e.target).//...",
                    "          g.hideEditCell();",
                    "        }",
                    "      }).on('keydown', function (e) {",
                    "        if (e.which === 27 && g.isCellEditActive) {",
                    "          // cancel on pressing \"Esc\"",
                    "          g.hideEditCell(true);"
                ],
                "uri": "js/dist/makegrid.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/dist/makegrid.js"
            },
            {
                "func": "HTMLHtmlElement.newFunc",
                "line": "229",
                "column": "23",
                "context": [
                    "   */",
                    "  wrapFunction: function (func) {",
                    "    if (!func.wrapped) {",
                    "      var newFunc = function () {",
                    "        try {",
                    "          return func.apply(this, arguments);",
                    "        } catch (x) {",
                    "          TraceKit.report(x);",
                    "        }",
                    "      };",
                    "      newFunc.wrapped = true;"
                ],
                "uri": "js/dist/error_report.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/dist/error_report.js"
            },
            {
                "func": "HTMLHtmlElement.dispatch",
                "line": "3",
                "column": "3086",
                "context": [
                    "(function(global,factory){\"use strict\";if(typeof module===\"object\"&&typeof //...",
                    "if((elem=matcherOut[i])&&(temp=postFinder?indexOf(seed,elem):preMap[i])>-1)//...",
                    "continue}special=jQuery.event.special[type]||{};type=(selector?special.dele//...",
                    "var tween=this.createTween(prop,value);adjustCSS(tween.elem,prop,rcssNum.ex//...",
                    "jQuery.globalEval(text);return text}}});jQuery.ajaxPrefilter(\"script\",funct//...",
                    ""
                ],
                "uri": "js/vendor/jquery/jquery.min.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/vendor/jquery/jquery.min.js"
            },
            {
                "func": "elemData.handle",
                "line": "2",
                "column": "31779",
                "context": [
                    "(function(global,factory){\"use strict\";if(typeof module===\"object\"&&typeof //...",
                    "if((elem=matcherOut[i])&&(temp=postFinder?indexOf(seed,elem):preMap[i])>-1)//...",
                    "continue}special=jQuery.event.special[type]||{};type=(selector?special.dele//...",
                    "var tween=this.createTween(prop,value);adjustCSS(tween.elem,prop,rcssNum.ex//...",
                    "jQuery.globalEval(text);return text}}});jQuery.ajaxPrefilter(\"script\",funct//...",
                    ""
                ],
                "uri": "js/vendor/jquery/jquery.min.js?v=5.2.1deb1%2Bfocal2",
                "scriptname": "js/vendor/jquery/jquery.min.js"
            }
        ],
        "incomplete": "false",
        "partial": "true",
        "uri": "index.php?route=%2Fsql&pos=0"
    }
}

报错界面

报错界面

内容的提问来源于stack exchange,提问作者Chief

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 04:39:51