相关疑难解决方法(0)

GSON Expected BEGIN_ARRAY but was BEGIN_OBJECT

I'm getting this error when I receive only one single item in a list. I'm using Jersey in the server side REST Web service, I only get the error when the List returned one single element and when it has 0 elements I get java.lang.NullPointerException But when it has more than one it works perfectly, and this is how I'm doing it :

@GET
@Path("getproject")
@Produces(MediaType.APPLICATION_JSON)
public List<Project> getPagedProjects(
       @QueryParam("offset") int offset,
       @QueryParam("limit") int limit,
       @QueryParam("searchKey") String searchKey) throws Exception …
Run Code Online (Sandbox Code Playgroud)

java android json jersey gson

12
推荐指数
2
解决办法
2万
查看次数

如何使用Jersey REST序列化Java基元

在我的应用程序中,我使用Jersey REST来序列化复杂对象.这很好用.但是有一些方法只返回一个int或boolean.

泽西岛无法处理原始类型(据我所知),可能是因为它们没有注释,而泽西没有默认注释.我通过创建像RestBoolean或RestInteger这样的复杂类型来解决这个问题,它只包含一个int或boolean值并具有相应的注释.

有没有比编写这些容器对象更简单的方法?

java rest primitive serialization jersey

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×2

jersey ×2

android ×1

gson ×1

json ×1

primitive ×1

rest ×1

serialization ×1