我有以下课程:
final class CFS {
public Map<String, String> files = new HashMap<String, String>();
public List<String> directories = new ArrayList<String>();
}
这段代码应该解析 json :
CFS cfs = JStorage.getGson().fromJson(JSON_STRING, CFS.class);
在哪里
JSON_STRING = "{\"directories\" : [\"folder1\", \"folder1/folder2\"], \"files\" : [{\"folder1\" : \"file.txt\"}, {\"folder1/folder2\" : \"file.cfg\"}]}"
JSON是:
{
"directories": ["folder1", "folder1/folder2"],
"files": [
{
"folder1": "file.txt"
},
{
"folder1/folder2": "file.cfg"
}
]
}
我得到的错误是:Expected BEGIN_ARRAY but was STRING at line 1 column 62
但我不知道为什么,根据 jsonlint,json 是有效的。
知道为什么我会收到此错误吗?