How to decode JSON values in my Android Aplication?

前端 未结 3 1525
死守一世寂寞
死守一世寂寞 2020-12-12 05:57

Hello guys I\'m trying to decode a JSON value into my Android Application, But I\'m not really sure What Am I doing wrong in my code...

This is my PHP file:

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 06:45

    I will try to answer :-

    1. As per your code you have this String ["1","Admin","123","Adm","messages","0"] which is clearly a jsonarray but you are parsing as jsonobject in android.

    2. as @Boban said you must not run network operations on main thread so avoid dat.

    Now taking the response as what i mentioned in 1 here is how you will do :-

    JSONArray jArray=new JSONArray(json_str)
    String id=jArray.getString(0);
    String admin=jArray.getString(1);
    .
    .
    .
    

    Hope it helps ... and if i m wrong please correct me :)

    thx

提交回复
热议问题