Here is the output that I need to parse. The values of usertype_name
should be stored into a String array. Please help me out.
{
0: {
usertype_name: "Member-Individual"
},
1: {
usertype_name: "Member-Institutional"
},
2: {
usertype_name: "Officer-Member"
},
3: {
usertype_name: "Officer-Admin"
},
4: {
usertype_name: "Officer-President"
},
current_position: "Member-Individual"
}
When parsing JSON on volley, normally I just do it like this:
public void onResponse(String s) {
JSONArray array= new JSONArray(s.toString());
for(int i = 0; i < array.length(); i++) {
JSONObject object = array.getJSONObject(i);
String text = object.getString("usertype_name");
}
}
But since there are incremental numbers showing on the result, which are weird for me, makes it confusing. Let me also post my webservice code. It goes like this, the usertype_name
are results of a query and the current_position
is a result of another query. If I'll remove the current_position
, the numbers will disappear.
$result = mysql_result(mysql_query($query),0);
$result2 = mysql_query($query2);
while($line = mysql_fetch_array($result2, MYSQL_ASSOC)){
$results[] = $line;
}
$results['current_position'] = $result;
echo (json_encode($results));