在Dart中使用JSON.decode时遇到此异常。关于如何解决这个问题有什么想法吗?
message: Class 'List' has no instance method 'codeUnitAt'.
这是它尝试解码的JSON数据:
[{_index: supply-desc-index, _type: supply-desc, _id: AVWeP5ZymMsGSnzRy9Kg, _score: 0.37158427, _source: {name: Test 3, description: test bdrwf, uom: EA, ipn: 1412341, mpn: 1234124, fireBaseKey: {description: test bdrwf, ipn: 1412341, mpn: 1234124, name: Test 3, uom: EA}}}, {_index: supply-desc-index, _type: supply-desc, _id: AVWeQ_56mMsGSnzRy9NG, _score: 0.37158427, _source: {name: Test, description: test 524, uom: EA, ipn: 42141, mpn: 124124, fireBaseKey: {description: test 524, ipn: 42141, mpn: 124124, name: Test, uom: EA}}}, {_index: supply-desc-index, _type: supply-desc, _id: 1, _score: 0.19178301, _source: {name: Test 3, description: test bdrwf, uom: EA, ipn: 1412341, mpn: 1234124, fireBaseKey: {description: test bdrwf, ipn: 1412341, mpn: 1234124, name: Test 3, uom: EA}}}, {_index: supply-desc-index, _type: supply-desc, _id: AVWeP6FsmMsGSnzRy9Kh, _score: 0.19178301, _source: {name: Test 3, description: test bdrwf, uom: EA, ipn: 1412341, mpn: 1234124, fireBaseKey: {description: test bdrwf, ipn: 1412341, mpn: 1234124, name: Test 3, uom: EA}}}]
最佳答案
一个问题是,您提供的数据-如果按字面意义进行处理-不是有效的JSON(但是,它是有效的YAML。)
如果所有键和值都用引号引起来,那么它将是有效的JSON。
(通过将数据粘贴到jsonlint.com和yamllint.com进行验证)。
数据来自哪里?
关于json - 使用JSON.decode的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38111669/