gpt4 book ai didi

java - 从流式 URL 读取 JSON 数据?

转载 作者:行者123 更新时间:2023-12-01 04:48:02 24 4
gpt4 key购买 nike

我正在尝试使用流式 URL 中的 JSON 数据

代码片段如下

   HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(url));

if(response.getEntity().isStreaming() ){
while (true) {
BufferedHttpEntity _entity = new BufferedHttpEntity(response.getEntity());
InputStream _stream = _entity.getContent();
JSONObject _interaction = new JSONObject(_stream.toString());
System.out.println(_interaction.toString());
}
}

请指导我在没有任何外部库的情况下使用它

提前致谢

最佳答案

您可以使用 DataContractJsonSerializer 在此处查看更多信息:http://msdn.microsoft.com/en-us/library/bb412179.aspx

关于java - 从流式 URL 读取 JSON 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15493613/

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