首页 > 解决方案 > 无法反序列化当前的 json 对象 当我尝试将以下 Json 数据读入对象时显示消息

问题描述

尝试将以下 JSON 内容反序列化为对象时遇到问题,尤其是eInv部分内容

{
    "requestType": "SaveDocuments",
    "status": "P",
    "version": "v0.1",
    "validationReport": null,
    "dataReport": [
        {
            "locationGstin": "DSAJJ0AAGCR31",
            "locationName": "ABC MARKET",
            "documentNumber": "2947",
            "documentDate": "23-10-2020",
            "billFromGstin": "DDLDF07AAGCL",
            "supplyType": "S",
            "documentType": "LST",
            "portCode": null,
            "custom1": null,
            "custom2": null,
            "custom3": null,
            "custom4": null,
            "custom5": null,
            "custom6": null,
            "custom7": null,
            "custom8": null,
            "custom9": null,
            "custom10": null,
            "eInv": {
                "ackNumber": "1721101",
                "ackDate": "01-02-2021 18:54:00",
                "irn": "2d9a39998157b984276e6f1d3b8f74597d7850f0b7ba88c251556e4436b2bb0e",
                "signedInvoice": "CJWeJKYynrWOw2k-GLO-vDipfOohtqW1xh5bg",
                "signedQRCode": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjQe5VoYONjADbEYzGABzAz8cCyLXDfNENkZ_TXHw",
                "qrCode": "iVBORw0KGgoAAAANSUhEUgAAAG0AAABtCAYAAACrXCIc",
                "qrCodeData": "{\"SellerGstin\":\"abc\",\"BuyerGstin\":\"def\",\"DocNo\":\"234\",\"DocTyp\":\"ghi\",\"DocDt\":\"23/10/2020\",\"TotInvVal\":4005.00,\"ItemCnt\":4,\"MainHsnCode\":\"abc\",\"Irn\":\"321absd432\",\"IrnDt\":\"2021-02-01 18:54:00\"}",
                "errors": null
            },
            "propertyErrors": null
        }
    ],
    "referenceId": "abcdesf="
}

标签: c#jsonjson-deserialization

解决方案


为自己找一个支持 JSON 的编辑器,例如 Visual Studio Code,或者任何在线 JSON 查看器的 Google,并养成使用这些工具检查 JSON 的习惯。

例如,https: //jsoneditoronline.org/#left=local.taxoru&right=local.hucize 在您的 JSON 中出现此错误:

Parse error on line 3:
...", "qrCodeData": "{"SellerGstin":"abc","
-----------------------^

删除第一个" 之后"qrCodeData":,你应该是有效的。


推荐阅读