无法正确转换JSON数据 [英] Cannot convert JSON data properly

查看:172
本文介绍了无法正确转换JSON数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图从此api中获取一些json数据: https://opentdb.com/api_config. php 用于我的测验应用程序,方法是使用排球库. 但是问题是,有时返回一些与实际数据混合的奇怪数据. 您会在句子的中间注意到'& quota'.

So i am trying to fetch some json data from this api : https://opentdb.com/api_config.php for my quiz app, by using volley library. But the problem is , it is sometimes returning a some weird data mixed up with the actual data. You can notice '&quota' in the middle of the sentence.

但是,当我在json查看器模式下查看它时,它就消失了

However when i view it in the json viewer mode, it was gone

即使在应用程序中它也显示相同,这是我转换json的代码:

Even in the app it is showing the same, here is my code to convert json :

 String results = response.getString("results");
                    JSONArray array_1 = new JSONArray(results);
                    JSONObject obj_1 = array_1.getJSONObject(0);
                    String incorrectAnswers = obj_1.getString("incorrect_answers");
                    JSONArray array_2 = new JSONArray(incorrectAnswers);

                    correctOption = obj_1.getString("correct_answer");
                    questionText.setText(obj_1.getString("question")); 

推荐答案

尝试转换您的String.

Try converting your String.

Html.fromHtml(obj_1.getString("question"));

这篇关于无法正确转换JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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