I'm trying to understand Koushi-ion's code so that i can get json data from website and input it into a listview. for now i am testing it with just a textview.
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.testview);
test = (TextView)findViewById(R.id.testview1);
Ion.with(getApplication(), "mywebsite")
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
// do stuff with the result or error
inputTest = result.getAsString();
test.setText(inputTest);
}
i get the logcat error :unsupportedoperationException: JsonObject at com.google.Gson.JsonElement.getAsString(JsonElement java:191);
Is it not that simple with Ion?
You're using Gson incorrectly. just use result.toString if you want the json as a string.