0

如果您使用的是 netbeans 7.3.1,您将获得 restful webservice 的 json,如下面的 myJson

[{"id":1,"name":"Appetizers","image":"iVBORw0KGgoAAAANSUhEUgAAADgAAAAkCAIAAABT8G6pAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABb5SURBVFhHPVgHUFPrtmbevTPvvnPvO8eKKJ1ASAik .. 

安卓代码

   Gson gson = new Gson();      
    try {                   
    Type collectionType = new TypeToken<Collection<Category>>(){}.getType();
    Collection<Category> enums = gson.fromJson(response, collectionType);

例外

 Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 39

我知道有类似的问题,但我尝试了很多,但我仍然有问题!这是我所有的 json 文件 https://docs.google.com/file/d/0B01ew9ECCvc8YVNiS1JmN2gwbDA/edit?usp=sharing

4

0 回答 0