Search code examples
androidandroid-ksoap2

How to read complex JSON in Android


If I have this string:

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; }; }; }; }; }; }; }; diffgram=anyType{DocumentElement=anyType{mytable=anyType{USER_ID=83; PROJECT_BY_DETAILS=An adaptation of a nursery rhyme into a dramatic film; }; mytable=anyType{USER_ID=88; PROJECT_BY_DETAILS=Test - over ye mountain blue ; }; }; }; }

How can I display it in an Android list view?

The expected output is:

USER_ID=83
PROJECT_BY_DETAILS=An adaptation of a nursery rhyme into a dramatic film

USER_ID=88
PROJECT_BY_DETAILS=Test - over ye mountain blue

Solution

  • String [] out;
    Int i = 0;
    //String result is your output (the code part from your question)
    While(Result.indexOf("USER_ID") != -1){
    Result = Result.substring(Result.indexOf ("USER_ID"),Result.length());
    out[i] =  Result.substring(0,Result.indexOf(";");
    Result = Result.substring(Result.indexOf (";"), Result.length());
    i++;
    }
    //out [] is your array with the data you want to have
    

    And with the array you can put the data in a listview. Hope this helps :)