编辑 json 文件时出现问题(错误:第 1 行解析错误:...期待"字符串"、"数字"'NULL'



我不是程序员,而是软件翻译,我收到了一份包含一些JSON文件的工作,必须对其进行编辑。很遗憾,当我使用 SDL Trados 的 Passollo 和任何其他 JSON 编辑程序 (http://jsoneditoronline.org/) 时,我收到以下错误消息:

Error: Parse error on line 1:
var start = [
    {
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'

下面的文件运行流畅,但是当我尝试编辑它们时,它们的语法有错误,解析器会检测到它们。

var start = [
    {
        type:   "top_img",
        child:  [
            {STRING
                id:"001",
                title:"POD Deck Lite-B1 Service Manual Rev0.0",
                href:"../frame_images/A021POD2-COVER-0001.gif"
            }
        ]
    },{
        type:   "menu",
        child:  [
            {
                id:"001",
                title:"Technology",
                description:"Technology"
            },{
                id:"002",
                title:"Service",
                description:"Service"
            },{
                id:"003",
                title:"Appendix",
                description:"Appendix"
            }
        ]
    },{
        type:   "reference",
        child:  [
            {
                id:"001",
                title:"How to use",
                src:"how to use",
                href:"../frame_htmls/how to use.html"
            },{
                id:"002",
                title:"Read me",
                src:"readme",
                href:"../frame_htmls/readme.html"
            },{
                id:"003",
                title:"Site map",
                src:"sitemap",
                href:"../frame_htmls/sitemap.html"
            },{
                id:"004",
                title:"History",
                src:"history",
                href:"../frame_htmls/history.xls"
            }
        ]
    },{
        type:   "header",
        child:  [
            {
                id:"001",
                title:"Home",
                href:"../esm.htm"
            },{
                id:"002",
                title:"Site map",
                href:"../frame_htmls/sitemap.html"
            }
        ]
    }
];

有人可以帮助我解决此错误消息,或者根据 json 解析器规则编辑 5 个文件,以便我将它们编辑为目标语言吗?

id 之前有一个不必要的STRING

确保所有属性名称都括在引号中。这应该有效。

[
   {
      "type":"top_img",
      "child":[
         {
            "id":"001",
            "title":"POD Deck Lite-B1 Service Manual Rev0.0",
            "href":"../frame_images/A021POD2-COVER-0001.gif"
         }
      ]
   },
   {
      "type":"menu",
      "child":[
         {
            "id":"001",
            "title":"Technology",
            "description":"Technology"
         },
         {
            "id":"002",
            "title":"Service",
            "description":"Service"
         },
         {
            "id":"003",
            "title":"Appendix",
            "description":"Appendix"
         }
      ]
   },
   {
      "type":"reference",
      "child":[
         {
            "id":"001",
            "title":"How to use",
            "src":"how to use",
            "href":"../frame_htmls/how to use.html"
         },
         {
            "id":"002",
            "title":"Read me",
            "src":"readme",
            "href":"../frame_htmls/readme.html"
         },
         {
            "id":"003",
            "title":"Site map",
            "src":"sitemap",
            "href":"../frame_htmls/sitemap.html"
         },
         {
            "id":"004",
            "title":"History",
            "src":"history",
            "href":"../frame_htmls/history.xls"
         }
      ]
   },
   {
      "type":"header",
      "child":[
         {
            "id":"001",
            "title":"Home",
            "href":"../esm.htm"
         },
         {
            "id":"002",
            "title":"Site map",
            "href":"../frame_htmls/sitemap.html"
         }
      ]
   }
]
function search(source) {
    //console.log("My Result: "+source);
    $.ajax({
        url: "index.ajax.php",
        type: "POST",
        cache: false,
        dataType: "json",
        data: { action:"search", source:source, form:$("form#main").serialize() },
        complete: function(data) {
            var d = JSON.stringify(data);
            //table
            $('#table_data').html(d.table);
            $("input[name='count']").val(d.count);
            $("#time").html(d.time);
            console.log("My Result: "+ d);
            //pagination
            from = Number($("input[name='start']").val());
            to = (Number(data.count) > (Number($("input[name='limit']").val())+from)) ? Number($("input[name='limit']").val())+from : data.count;
            if(data.count == 0) {
                $('#page_info').html('<p>No results found.</p>');
                $('#next').hide();
            } else {
                $('#page_info').html('<p>Showing '+(from+1)+' to '+to+' of '+data.count+'  records in total.</p>');
                $('#next').show();
            }
        },
        error: function(data) {
            $('#table_data').html('<tr><td colspan="20">Results error. Please contact admin.</td><tr>');
            $("#page_info").html("<p>Load error.</p>");
        }
        /*        error:function(x,e) {
         if (x.status==0) {
         alert('You are offline!!n Please Check Your Network.');
         } else if(x.status==404) {
         alert('Requested URL not found.');
         } else if(x.status==500) {
         alert('Internel Server Error.');
         } else if(e=='parsererror') {
         alert('Error.nParsing JSON Request failed.');
         } else if(e=='timeout'){
         alert('Request Time out.');
         } else {
         alert('Unknown Error.n'+x.responseText);
         }
         }*/
    });
}

相关内容

最新更新