Error in REst response in java, object is not displayed as Json array

1

When it shows the result in Json of several records of the Rest that I have developed if it shows it as an array (with a bracket that encloses all the elements):

{"tb_tipo_producto_1":[{"c_t_tipo_producto":"ACCESORIO PARA COCINA","n_i_cant_productos":"6","n_n_tipo_producto":"010000000"},{"c_t_tipo_producto":"AUTO","n_i_cant_productos":"7","n_n_tipo_producto":"001000000"}]}

But when the result is a single element it does not show the bracket:

{"tb_tipo_producto_1":{"c_t_tipo_producto":"CAJAS","n_i_cant_productos":"2","n_n_tipo_producto":"005011035"}}

The method I use is the following:

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/findallsp/{id}")
public Response findAllSP(@PathParam(value = "id") String id    ) {
    Tb_tipo_producto_1Model pm = new Tb_tipo_producto_1Model();
    return Response 
            .ok()
            .entity(new GenericEntity<List<Tb_tipo_producto_1>>(pm.findAllSP( id ))  {
            })
            .header("Access-Control-Allow-Origin", "*")
            .header("Access-Control-Allow-Methods",
                    "GET, POST, DELETE, PUT, OPTIONS, HEAD").build();
}
    
asked by RLAPeru2 17.08.2017 в 17:09
source

0 answers