为什么不会有任何C#JSON类生成器处理这个JSON对象?

时间:2013-09-04 00:24:39

标签: c# json

我尝试了3种不同的JSON类生成器,但是当我尝试从以下JSON输出生成C#类时出现错误:

{
"status": "REQUEST_STATUS",
"language": "DOCUMENT_LANGUAGE",
"url": "REQUESTED_URL",
"text": "DOCUMENT_TEXT",
"entities": [
    "entity": {
        "type": "DETECTED_TYPE",
        "relevance": "DETECTED_RELEVANCE",
        "count": "DETECTED_COUNT",
        "text": "DETECTED_ENTITY"
        "disambiguated": {
            "name": "DISAMBIGUATED_ENTITY",
            "subType": "ENTITY_SUBTYPE",
            "website": "WEBSITE",
            "geo": "LATITUDE LONGITUDE",
            "dbpedia": "LINKED_DATA_DBPEDIA",
            "yago": "LINKED_DATA_YAGO",
            "opencyc": "LINKED_DATA_OPENCYC",
            "umbel": "LINKED_DATA_UMBEL",
            "freebase": "LINKED_DATA_FREEBASE",
            "ciaFactbook": "LINKED_DATA_FACTBOOK",
            "census": "LINKED_DATA_CENSUS",
            "geonames": "LINKED_DATA_GEONAMES",
            "musicBrainz": "LINKED_DATA_MUSICBRAINZ",
            "crunchbase": "CRUNCHBASE_WEB_LINK",
        },
        "quotations": [
            {
                "quotation": "ENTITY_QUOTATION"
            }
        ],
        "sentiment": {
            "type": "SENTIMENT_LABEL",
            "score": "SENTIMENT_SCORE",
            "mixed": "SENTIMENT_MIXED"
        }
    }
  ]
}

错误位于以下行,括号:

"entities": [

但是我使用上述两个工具找到的所有例子都有使用像我这样的数组的例子,那么为什么我的例子会引起异常。例外是“无效字符和第7行位置17。

如果我将直括号更改为currly括号,它会生成但是这会改变类,对吗?

1 个答案:

答案 0 :(得分:0)

数组内部的东西本身没有名称所以只需更改

"entities": [
   "entity": {
      "type": "DETECTED_TYPE",

"entities": [ {
   "type": "DETECTED_TYPE",