JSON Responce数据访问控制台我使用Java,Eclipse,Tomcat [英] JSON Responce data Getting at Console i used Java,Eclipse,Tomcat

查看:225
本文介绍了JSON Responce数据访问控制台我使用Java,Eclipse,Tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦检查这张图像,并告诉我如何解决这个

once check this images,.. and tell me how to fix this

我应用了上面的Json数组和此链接中的Json对象

I applied the above Json array and Json Object in this link

但当我运行它,....这个响应我正在进入,...告诉我如何给这个数据在Url,..在本地主机的tomcat ......

but when i run it,.... this responce i am getting in consloe,... Tell me how to give this data in Url,.. at local host of tomcat......

,并且还可以看到这个链接了解更多细节,.. 如何使用Java eclipse Tomcat7.0为巨大的JSON数据创建一个可靠的服务

and also see this link for more details,.. How to Create a Restful service for a Huge JSON data using Java eclipse Tomcat7.0

推荐答案

你的import语句是什么样的?我使用org.json。*

What does your import statement look like? I use org.json.*

首先你需要将json字符串转换成一个字符串,读取它与BufferedReader一行。

first you need to get the json string into a string reading it line by line with a BufferedReader.

那么你应该有

JSONObject jsonObject = new JSONObject(json);

其中json是当您使用BufferedReader读取它时获得的字符串

where json is the string that you got when you read it with the BufferedReader

这是一个例子:

try {

        InputStream is = new URL(url).openStream();
        BufferedReader rd = new BufferedReader(
                    new InputStreamReader(is, Charset.forName("UTF-8")));
        try {
        String json = rd.readLine();
        } finally {
            rd.close();
        }
        }  catch (Exception e) {
            System.out.println(e.toString());
        } 

JSONObject obj = new JSONObject(json);

这篇关于JSON Responce数据访问控制台我使用Java,Eclipse,Tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆