Jeg haaber at det er dette her du har:
package january;
import org.json.JSONArray;
import org.json.JSONObject;
public class JsonParse {
public static void main(String[] args) {
String json = "{\"ValidateUserByUGUIDResult\":[{\"UserIsValidated\":true}]}";
System.out.println(json);
JSONObject obj = new JSONObject(json);
JSONArray vup = obj.getJSONArray("ValidateUserByUGUIDResult");
for(int i = 0; i < vup.length(); i++) {
JSONObject elm = vup.getJSONObject(i);
boolean isval = elm.getBoolean("UserIsValidated");
System.out.println(isval);
}
}
}
Men som JSOn ser ud i spoergsmaalet saa kunne du have dette her mystiske dobbelt JSON encodet:
package january;
import org.json.JSONArray;
import org.json.JSONObject;
public class FunkyJsonParse {
public static void main(String[] args) {
String json = "{\"ValidateUserByUGUIDResult\":\"[{\\\"UserIsValidated\\\":true}]\"}";
System.out.println(json);
JSONObject obj = new JSONObject(json);
String vupstr = obj.getString("ValidateUserByUGUIDResult");
JSONArray vup = new JSONArray(vupstr);
for(int i = 0; i < vup.length(); i++) {
JSONObject elm = vup.getJSONObject(i);
boolean isval = elm.getBoolean("UserIsValidated");
System.out.println(isval);
}
}
}