【问题标题】:I am facing issue when converting json to dart, below is the json将 json 转换为 dart 时遇到问题,下面是 json
【发布时间】:2021-09-25 22:58:58
【问题描述】:

IN this you can find the error when json is converted当我使用 https://javiercbk.github.io/json_to_dart/ 将下面的 json 转换为 dart 时,它说“生成的 Dart 代码无效”。我正在使用未来的构建器在用户界面中显示响应。 当我注释掉“状态”类时,错误发生但没有显示响应。


      {
                  "result": {
                      "userDetails": {
                          "digilockerid": "...digilockerid...",
                          "name": "...name...",
                          "dob": "...dob...",
                          "gender": "...M/F/T...",
                          "eaadhaar": "...Y or N as per availability..."
                      },
                      "files": [{
                          "name": "Aadhaar Card",
                          "type": "file",
                          "size": "",
                          "date": "...date...",
                          "parent": "",
                          "mime": [
                              "application/pdf",
                              "application/xml",
                              "application/json"
                          ],
                          "doctype": "...5 letter DOC key...",
                          "description": "...Description...",
                          "issuerid": "...issuer id...",
                          "issuer": "...issuer name...",
                          "id": "...unique file ID..."
                      }],
                      "eAadhaar": {
                          "name": "...name...",
                          "dob": "...date of birth...",
                          "uid":"...uid...",
                          "gender": "...gender...",
                          "x509Data": {
                              "validAadhaarDSC": "...is eaadhaar certificate valid or not (yes/no)..."
                          },
                          "address": "...address",
                          "photo": "...link to photo as on eaadhaar...",
                          "splitAddress": {
                              "district": [
                                  "...district name..."
                              ],
                              "state": [
                                  [
                                      "...state name...",
                                      "...2 digit state code..."
                                  ]
                              ],
                              "city": [
                                  "...city name..."
                              ],
                              "pincode": "...pincode...",
                              "country": [
                                  "...2 digit ISO country name...",
                                  "...3 digit ISO country name...",
                                  "...country name..."
                              ],
                              "addressLine": "...address..."
                          }
                      }
                  }
              }

【问题讨论】:

  • 您使用的是空安全吗?
  • noo ,这与空安全无关。在线将json转换为对象时会出现此问题

标签: json flutter dart flutter-dependencies


【解决方案1】:

我不知道这是否适合你,但它有效,我改变了这个:

"state": [
      [
           "...state name...",
           "...2 digit state code..."
                                  ]
                              ]

到这里:

"state": [
             "...state name...",
             "...2 digit state code..."
             ]
                              

而且它没有显示无效的飞镖代码消息

【讨论】:

  • 是的,错误消失了,bt im nt 得到响应 json
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-08-05
  • 1970-01-01
  • 2019-12-20
  • 2022-01-17
  • 1970-01-01
  • 2015-07-03
  • 1970-01-01
相关资源
最近更新 更多