1

I have an array like this:

[{"poolkost":"IWXI"},{"poolkost":"ILXI"},{"poolkost":"VGXI"}]

and want to put it in a List using the tutorial How to convert JSONArray to List with Gson?

My Code:

    String jsonStr = DBFunction.GetBoxer(GlobalClass.DIR);
    Gson gson = new Gson();
    Type listType = new TypeToken<List<String>>(){}.getType(); //ERROR 1
    List<String> PoolList = gson.fromJson(jsonStr, listType);  //ERROR 2

I get 2 errors:

Error 1:

Type mismatch: cannot convert from java.lang.reflect.Type to android.renderscript.Type

Error 2:

The method fromJson(String, Class<T>) in the type Gson is not applicable for the arguments (String, Type)

I cannot fix the first Error, either the second...

Community
  • 1
  • 1
zauber3r
  • 95
  • 1
  • 7

1 Answers1

2

Check your imports.

Remove this:

import android.renderscript.Type;

Add this:

import java.lang.reflect.Type;

This should fix both problems.

durron597
  • 31,968
  • 17
  • 99
  • 158