【发布时间】:2019-06-16 06:56:34
【问题描述】:
我正在尝试使用 json.decode(myString) 将 json 字符串解析为 HashMap,但出现错误。
以下是我的json字符串:
{
'id':'5043' ,
'artist':'Axwell Λ Ingrosso' ,
'title':'More Than You Know' ,
'displayName':'FDM Axwell Ingrosso.mp3' ,
'duration':'203050',
'path':'/storage/emulated/0/UCDownloads/FDM_Axwell_Ingrosso.mp3'
}
我正在使用 jsong.decode(aboveString) 进行转换,但出现以下错误:
FormatException: Unexpected character (at character 2) {'id':'5043' ,'artist':'Axwell Λ Ingrosso' ,'title':'More Than You Know'
【问题讨论】:
-
一些 JSON 解析器可以处理单引号,但远非如此,所以我认为使用双引号可能会解决您的问题。
-
如前所述,JSON 不支持单引号。但是,如果您无法更改数据格式,则可以改用yaml 解析器。
标签: flutter