java - 在 TextView 中显示 JSONStringer 结果

标签 java android json string

你好,我是 webservices 和 json 的新手,所以我请求你帮助如何在 textView 中显示 JSONStringer 结果。

这是我正在处理的代码:

           // Build JSON string
           JSONStringer TestApp = new JSONStringer().object().key("id")
                        .value("1").key("name").value("manish").key("email")
                        .value("androidhub4you@gmail.com").key("country")
                        .value("india").endObject();
           String entity = new StringEntity(TestApp.toString());
           String var = entity.toString();

显示:

                TextView tv  = (TextView) findViewById (R.id.tvText);
        tv.setText(var);

问题是它只是打印

   org.apache.http.entity StringEntity....

。我非常感谢你的帮助。提前致谢。

最佳答案

改变

String var = entity.toString();

String var = EntityUtils.toString(entity)

StringEntity.toString()返回对象的地址

关于java - 在 TextView 中显示 JSONStringer 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16997114/

相关文章:

java - LinkedLIst indexOf递归实现

android - EditText 中的光标位置

android - React-native + Relay.js 的稳定构建

java - GWT JSONObject 覆盖类型(或在共享中使用 JSONObject)

java - 通用列表中的编译错误

Java Swing : Showing tool tip in JTable based on text under mouse pointer

java - 如何在 Hibernate 应用程序中处理数据库空值?

Android蓝牙崩溃应用程序

java - Android JSON通过HttpURLConnection获取错误405

php - 使用 PHP (curl) 从 JSON (Google Maps API) 中提取数据