gpt4 book ai didi

java - 我收到如下所示的 HTTP 响应字符串。我想要响应字符串中的 subject_id 和状态字符串

转载 作者:行者123 更新时间:2023-12-01 08:47:16 25 4
gpt4 key购买 nike

响应字符串是这样的:

{
"images": [
{
"transaction": {
"status": "success",
"topLeftX": 325,
"topLeftY": 451,
"gallery_name": "Ironman",
"subject_id": "Tony",
"confidence": 0.99414,
"height": 630,
"width": 630,
"face_id": 1,
"quality": 1.75477
},
"candidates": [
{
"subject_id": "Tony",
"confidence": 0.99414,
"enrollment_timestamp": "1487644861022"
},
{
"subject_id": "Tony",
"confidence": 0.99414,
"enrollment_timestamp": "1487644876280"
}
]
}
]
}

我尝试了这段代码但不起作用..

JSONArray arr = new JSONArray(response); 
JSONObject jObj = arr.getJSONObject(0);
String status = jObj.getString("status");
String message = jObj.getString("subject_id");
<小时/>

最佳答案

使用json简单lib

JSONObject json = new JSONObject(yourString);
JSONArray images = json.getJSONArray("images");

你可以循环抛出这个数组

for (int i = 0; i < images.length(); i++) {
JSONObject o = images.getJSONObject(i);
....
}

关于java - 我收到如下所示的 HTTP 响应字符串。我想要响应字符串中的 subject_id 和状态字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42599808/

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