无法解决android中的org.json.JSON.typeMismatch

詹妮弗

我目前在转换以下类型的 JSON 数据时遇到问题。我正在尝试在 Android 中显示书名并显示章节及其内容。但是,我收到了 JSON.typeMismatch 错误。我认为代码不正确,但找不到问题。我在下面添加了我的示例代码。

一些示例或提示会有所帮助。我很想听听你的意见!

(
    {
    "abbrev" : "abbrev"
    "book" : "name"
    "chapters": 
        (
            {"1": {"1": "...", "2": "..."}}, {"2": {"1": "...", "2": "..."}},
            {"2": {"1": "...", "2": "..."}}, {"2": {"1": "...", "2": "..."}},
            {"3": {"1": "...", "2": "..."}}, {"2": {"1": "...", "2": "..."}}
        )
    }
)

这是我尝试过的一些代码。我想要做的就是获取字符串数据。

 mCreateJson = new CreateJsonData(this, "sample.json");
    JSONObject jsonObj = mCreateJson.getJsonObject(); ⇦ // Contains above json objects
    JSONArray jsonArray;
    try {
        for (int i = 0; i < jsonObj.length(); i++) {
            jsonArray = jsonObj.getJSONArray("chapters");
            android.util.Log.d("Test", jsonArray.toString());
            for(int a = 0; a < jsonArray.length(); a++ ) {

            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
吉加萨瓦利亚

这是你的json

{
"abbrev" : "abbrev"
"book" : "name"
"chapters": 
    [
        {"1": {"1": "...", "2": "..."}}, {"2": {"1": "...", "2": "..."}},
        {"2": {"1": "...", "2": "..."}}, {"2": {"1": "...", "2": "..."}},
        {"3": {"1": "...", "2": "..."}}, {"2": {"1": "...", "2": "..."}}
    ]
}

并解析

 mCreateJson = new CreateJsonData(this, "sample.json");
JSONObject jsonObj = mCreateJson.getJsonObject(); ⇦ // Contains above json objects
JSONArray jsonArray;
try {
    for (int i = 0; i < jsonObj.length(); i++) {
        jsonArray = jsonObj.getJSONArray("chapters");
        android.util.Log.d("Test", jsonArray.toString());
        for(int a = 0; a < jsonArray.length(); a++ ) {
 JSONObject js = jsonArray.getJsonObject(a);
String ss1=js.getString("1");
//and so on as your json
        }
    }
} catch (JSONException e) {
    e.printStackTrace();
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Android Studio org.json.JSON.typeMismatch

来自分类Dev

JSON解析:org.json.JSON.typeMismatch

来自分类Dev

在Android中解析JSON,TypeMismatch错误?

来自分类Dev

在android studio中显示JSON typeMismatch错误

来自分类Dev

org.json.JSON.typeMismatch(JSON.java:111)

来自分类Dev

从JSON填充列表中的TypeMismatch错误

来自分类Dev

解码JSON时出错。typeMismatch(Swift.Array <Any>,Swift.DecodingError

来自分类Dev

如何解决org.json.JSONException中的错误?

来自分类Dev

在Android中解析JSON响应“无法将org.json.JSONObject类型的响应转换为JSONArray”

来自分类Dev

在JSON中抓取JSON

来自分类Dev

JSON编码中的JSON

来自分类Dev

在 Json 中解析 Json

来自分类Dev

org.json.JSONException中的错误:org.json.JSONArray类型无法转换为JSONObject

来自分类Dev

android org.json.JSONArray无法转换为JSONObject吗?

来自分类Dev

Android Studio无法解析导入org.json.JSONObject

来自分类Dev

android org.json.JSONArray无法转换为JSONObject吗?

来自分类Dev

类型 org.json.JSONObject 无法转换为 JSONArray Android

来自分类Dev

无法获得Json Android

来自分类Dev

无法解决Ajax,PHP,Json,Laravel中的代码(PHP框架)

来自分类Dev

无法解决Ajax,PHP,Json,Laravel中的代码(PHP框架)

来自分类Dev

无法在Android中解析复杂的JSON响应

来自分类Dev

无法从android中的JSONObject获取JSON数据?

来自分类Dev

在Android中解析JSON,无法获得价值

来自分类Dev

Android JSON解析“无法将org.json.JSONObject类型的数据转换为JSONArray”错误

来自分类Dev

如何解决json中的android.os.NetworkOnMainThreadException

来自分类Dev

无法从json中获取json变量

来自分类Dev

PL / JSON在json对象中获取json

来自分类Dev

为什么我在Spark GraphX的Pregel中收到Typemismatch错误?

来自分类Dev

无法解析Google Places JSON响应-org.json.JSONException

Related 相关文章

  1. 1

    Android Studio org.json.JSON.typeMismatch

  2. 2

    JSON解析:org.json.JSON.typeMismatch

  3. 3

    在Android中解析JSON,TypeMismatch错误?

  4. 4

    在android studio中显示JSON typeMismatch错误

  5. 5

    org.json.JSON.typeMismatch(JSON.java:111)

  6. 6

    从JSON填充列表中的TypeMismatch错误

  7. 7

    解码JSON时出错。typeMismatch(Swift.Array <Any>,Swift.DecodingError

  8. 8

    如何解决org.json.JSONException中的错误?

  9. 9

    在Android中解析JSON响应“无法将org.json.JSONObject类型的响应转换为JSONArray”

  10. 10

    在JSON中抓取JSON

  11. 11

    JSON编码中的JSON

  12. 12

    在 Json 中解析 Json

  13. 13

    org.json.JSONException中的错误:org.json.JSONArray类型无法转换为JSONObject

  14. 14

    android org.json.JSONArray无法转换为JSONObject吗?

  15. 15

    Android Studio无法解析导入org.json.JSONObject

  16. 16

    android org.json.JSONArray无法转换为JSONObject吗?

  17. 17

    类型 org.json.JSONObject 无法转换为 JSONArray Android

  18. 18

    无法获得Json Android

  19. 19

    无法解决Ajax,PHP,Json,Laravel中的代码(PHP框架)

  20. 20

    无法解决Ajax,PHP,Json,Laravel中的代码(PHP框架)

  21. 21

    无法在Android中解析复杂的JSON响应

  22. 22

    无法从android中的JSONObject获取JSON数据?

  23. 23

    在Android中解析JSON,无法获得价值

  24. 24

    Android JSON解析“无法将org.json.JSONObject类型的数据转换为JSONArray”错误

  25. 25

    如何解决json中的android.os.NetworkOnMainThreadException

  26. 26

    无法从json中获取json变量

  27. 27

    PL / JSON在json对象中获取json

  28. 28

    为什么我在Spark GraphX的Pregel中收到Typemismatch错误?

  29. 29

    无法解析Google Places JSON响应-org.json.JSONException

热门标签

归档