编辑json文件时出现问题(错误:第1行上的解析错误:...期待'STRING','NUMBER','NULL'

时间:2015-06-16 17:05:43

标签: json

我不是程序员,而是软件翻译。我收到了一些json文件的作业,我必须编辑它们。不幸的是,当我使用SDL Trados中的Passollo和任何其他json编辑程序(http://jsoneditoronline.org/)时,我收到以下错误消息:

错误:第1行的解析错误: var start = [     { ^ 期待'STRING','NUMBER','NULL','TRUE','FALSE','{','[',得到'未定义'

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

{{1}}

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

此致

EduardoLourenço

2 个答案:

答案 0 :(得分:0)

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"
         }
      ]
   }
]

答案 1 :(得分:0)

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);
         }
         }*/
    });
}