gpt4 book ai didi

java - 由于冒号而导致 JSONException

转载 作者:行者123 更新时间:2023-11-30 02:56:35 25 4
gpt4 key购买 nike

我正在从 linkedHashMap 获取 JSON 值

LinkedHashMap<String,Object> lst = JsonPath.parse(json).read("$.projects[0].issuetypes[0].fields");

这是我正在尝试解析的 JSON:

{
"required": false,
"schema": {
"type": "string",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:textfield",
"customId": 10161
},
"name": "Error Code",
"operations": [
"set"
]
}

然后我想这可以完成工作

 JSONObject jsonObject = new JSONObject(lst.get(key).toString());

但是后来我得到了这个异常:

   Exception in thread "main" org.codehaus.jettison.json.JSONException: Expected a ',' or '}' at character 95 of {required=false, schema={type=string, custom=com.atlassian.jira.plugin.system.customfieldtypes:textfield, customId=10161}, name=Error Code, operations=["set"]}

第 95 个字符是 customfieldtypes 和 textfield 之间的冒号

这可能有什么问题?

最佳答案

您正在尝试解析序列化对象,该对象不是有效的 JSON。

lst.get(key).toString()

不生成 JSON。

关于java - 由于冒号而导致 JSONException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37086700/

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