简体   繁体   English

json数组,其中in数组返回错误?坏字符串

[英]json array with in array returning error ?bad string

i am parsing my json string file to python and always returning error . 我将json字符串文件解析为python,并且始终返回error。 i used online json formatter and validators that also returning error so i want help to make my json correct and tell me error 我使用了在线json格式化程序和验证器,它们也返回错误,因此我需要帮助使我的json正确并告诉我错误

 [{
     "sentence_id": "TR.00001",
     "sentence": {

         "text": "Bill was born 1986.",
         "annotation": {
             (1, "Bill", "bill", "NNP", "B-PERSON"),
             (2, "was", "be", "VBD", "O"),
             (3, "born", "bear", "VBN", "O"),
             (4, "1986", "BIL", "CD", "B-DATE"),
             (5, ".", ".", ".", "O"),

         },
         "relations": {
             "subject": "bill",
             "predicate": "DATE of Birth",
             "object": "1986"
         }
     }
 }, ]

the above is my json string you can check online validators or online json format verifier here is the part of json that returns error 上面是我的json字符串,您可以检查在线验证器或在线json格式验证器,这是返回错误的json部分

"annotation": {
    (1, "Bill", "bill", "NNP", "B-PERSON"),
    (2, "was", "be", "VBD", "O"),
    (3, "born", "bear", "VBN", "O"),
    (4, "1986", "BIL", "CD", "B-DATE"),
    (5, ".", ".", ".", "O"),
},

so can you please help me in sorting out the trouble of array with in array using json you can use these editors link link to json editor 所以你能帮我用json在数组中解决数组的麻烦吗?你可以使用这些编辑器链接到json编辑器的链接

expecting property name , error in line 8 期望属性名称,第8行出错

JSON doesn't understand tuples, try changing to lists: JSON不了解元组,请尝试更改为列表:

"annotation": [
    [1, "Bill", "bill", "NNP", "B-PERSON"],
    [2, "was", "be", "VBD", "O"],
    [3, "born", "bear", "VBN", "O"],
    [4, "1986", "BIL", "CD", "B-DATE"],
    [5, ".", ".", ".", "O"]
]

You can do tuple(list) to convert back to tuples on the other end. 您可以执行tuple(list)以将其转换回另一端的元组。

Also, you had an extra comma on [5, ".", ".", ".", "O"] , I removed it. 另外,您在[5, ".", ".", ".", "O"]上有一个逗号,我将其删除。

Your json string file is not proper it have some error ... 您的json字符串文件不正确,有一些错误...

  1. you missed the key in annotation. 您错过了注释中的键。
  2. your value must be in capital bracket because it is an array. 您的值必须在大括号中,因为它是一个数组。
  3. you add extra comma at the end. 您在末尾添加了逗号。

      [ { "sentence_id" : "TR.00001", "sentence" : { "text" : "Bill was born 1986.", "annotation":{ "1": [1,"Bill" , "bill" , "NNP" ,"B-PERSON"], "2":[2, "was" , "be" , "VBD" , "O"], "3": [3 , "born" , "bear" , "VBN", "O"], "4":[4, "1986" , "BIL" , "CD" , "B-DATE"], "5":[5, "." , "." , ".","O"] }, "relations":{ "subject":"bill", "predicate":"DATE of Birth", "object":"1986" } } } ] 

That means your annotation section must be like this: 这意味着您的注释部分必须是这样的:

"annotation":{
              "1": [1,"Bill" , "bill" , "NNP" ,"B-PERSON"],
              "2":[2, "was" , "be" , "VBD" , "O"],
              "3": [3 , "born" , "bear" , "VBN", "O"],
              "4":[4, "1986" , "BIL" , "CD" , "B-DATE"],   
              "5":[5, "." , "." , ".","O"]
             },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM