Web服务中的JSON

时间:2018-10-09 02:37:15

标签: java json web-services

如果要在Web服务中实现JSON,是否有任何限制?

我有一个Java代码,并尝试在Java程序可执行文件中运行。可以。

sql = "SELECT attributes FROM common_attr_test";
            stmt = (Statement) conn.createStatement();
            rst = stmt.executeQuery(sql);

            while (rst.next()) {
                 valueAttributes = rst.getString("attributes"); //get value for database                    
            }

              JSONObject obj = new JSONObject(valueAttributes);

              //For Time_Login

             System.out.println("obj is"+obj);

我得到的结果是:

obj is{"1":[{"entry":"3","count":1}],"2":[{"entry":"https://uap.mimos.my/owa","count":1}],"3":[{"entry":"Chrome|Windows NT 6.1","count":1}],"4":[],"7":[{"entry":"1","count":1}],"8":[{"entry":"1","count":1}]}

但是,当在一个Web服务功能中写入相同的代码时,它没有显示预期的结果。它停留在:

JSONObject obj = new JSONObject(valueAttributes);

出现肥皂错误:

<faultcode>soapenv:Server</faultcode>
     <faultstring>org/json/JSONObject</faultstring>

网络服务中的代码:

sql = "SELECT attributes FROM common_attr_test WHERE uuid='"+uuID+"'";
        stmt = (Statement) conn.createStatement();
        rst = stmt.executeQuery(sql);
while (rst.next()) {
             valueAttributes = rst.getString("attributes"); //get value for database                    
        }

        logWriter("valueAttributes from database : "+valueAttributes);

        //test 9 oct

            JSONObject obj = new JSONObject(valueAttributes);

当我们想在普通Java程序或Web服务程序中实现代码时,有什么不同吗?有依赖性吗?

谢谢。

0 个答案:

没有答案