Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Android - JSON Parser attraverso richiesta http
Forum - Android - JSON Parser attraverso richiesta http

Avatar
domenico_rizzo (Normal User)
Pro


Messaggi: 90
Iscritto: 27/07/2015

Segnala al moderatore
Postato alle 17:01
Martedì, 17/04/2018
Ciao allora la mia app fa una richiesta http, e ottenendo il json di risposta vorrei poter creare oggetti secondo mie necessita'.. ma inspiegabilmente mi crasha mentre ottengo il parse del JSON dalla richiesta mentre cerco di ottenere informazioni :_doubt:

risposta json:
Codice sorgente - presumibilmente Plain Text

  1. [
  2.         {
  3.                 "id":1,
  4.                 "str1":2,
  5.                 "str2":null,
  6.                 "str3":"ss1",
  7.                 "str4":null,
  8.                 "str5":12.34566789,
  9.                 "str6":98.76543210,
  10.                 "str7":0,
  11.                 data: [
  12.                         {
  13.                                 "id":3,
  14.                                 "str8":4,
  15.                                 "str9":5,
  16.                                 "str10":"ss2",
  17.                                 "str11":"ss3",
  18.                                 "str12":null,
  19.                                 "str13":null,
  20.                                 "str14":1,
  21.                                 data: [
  22.                                         {
  23.                                                 "id":6,
  24.                                                 "str15":7,
  25.                                                 "str16":8,
  26.                                                 "str17":"ss4",
  27.                                                 "str18":"ss5",
  28.                                                 "str19":null,
  29.                                                 "str20":null,
  30.                                                 "str21":2
  31.                                         },
  32.                                         {
  33.                                                 "id":9,
  34.                                                 "str22":10,
  35.                                                 "str23":11,
  36.                                                 "str24":"ss6",
  37.                                                 "str25":"ss7",
  38.                                                 "str26":null,
  39.                                                 "str27":null,
  40.                                                 "str28":2
  41.                                         }
  42.                                 ]
  43.                         },
  44.                         {
  45.                                 "id":12,
  46.                                 "str29":13,
  47.                                 "str30":14,
  48.                                 "str31":"ss8",
  49.                                 "str32":"ss9",
  50.                                 "str33":null,
  51.                                 "str34":null,
  52.                                 "str35":1,
  53.                                 data: [
  54.                                         {
  55.                                                 "id":15,
  56.                                                 "str35":16,
  57.                                                 "str36":17,
  58.                                                 "str37":"ss10",
  59.                                                 "str38":"ss11",
  60.                                                 "str39":null,
  61.                                                 "str40":null,
  62.                                                 "str41":2
  63.                                         },
  64.                                         {
  65.                                                 "id":18,
  66.                                                 "str42":19,
  67.                                                 "str43":20,
  68.                                                 "str44":"ss12",
  69.                                                 "str45":"ss13",
  70.                                                 "str46":null,
  71.                                                 "str47":null,
  72.                                                 "str48":2
  73.                                         }
  74.                                 ]
  75.                         }
  76.                 ]
  77.         }
  78. ]



richiamo una funzione in cui vorrei gestire il risultato della chiamata json:
Codice sorgente - presumibilmente C#

  1. //prepareList( new JSONObject(string_json) ); chiamo in questo modo la suddetta funzione
  2.  
  3. private void prepareList(JSONObject jso) throws JSONException {
  4.         Log.d("RESULT", jso.toString());
  5.         int id = jso.getInt("id");
  6.         int str1 = jso.getInt("str1");
  7.         Log.d("RESULT", id+"\n"+str1);
  8. }



Sapreste aiutarmi?? :d

Ultima modifica effettuata da domenico_rizzo il 17/04/2018 alle 17:28
PM Quote
Avatar
tuttodiMC (Normal User)
Expert


Messaggi: 327
Iscritto: 29/10/2012

Segnala al moderatore
Postato alle 14:11
Lunedì, 30/04/2018
Potresti recuperare il nome dell'eccezione che viene creata?

PM Quote
Avatar
tuttodiMC (Normal User)
Expert


Messaggi: 327
Iscritto: 29/10/2012

Segnala al moderatore
Postato alle 14:11
Lunedì, 30/04/2018
Potresti recuperare il nome dell'eccezione che viene creata?

PM Quote