gpt4 book ai didi

java - Gson 预期为 BEGIN_ARRAY 但在第 1 行第 62 列为 STRING

转载 作者:搜寻专家 更新时间:2023-10-31 08:27:11 24 4
gpt4 key购买 nike

<分区>

我有以下类(class):

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 是有效的。

知道我为什么会收到此错误吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com