0

I'm using jersey to generate jsonp that will activate a jQuery callback to populate an autocomplete. However, the generated jsonp is syntactically incorrect as it causes a javascript error with the message:

'SyntaxError: missing ) after argument list'

And my browser is right. This is the jsonp that is returned from the server:

jQuery18204124785447421858_1369727990195("[{\"firstname\":\"Carl\",\"lastname\":\"xxxxxx\",\"nihii\":\"140xxxxxx\"},{\"firstname\":\"Bram\",\"lastname\":\"xxxxxxxxx\",\"nihii\":\"102xxxxx\"},{\"firstname\":\"Carl\",\"lastname\":\"Mxxxxxx\",\"nihii\":\"1403xxxxxx\"},{\"firstname\":\"Max\",\"lastname\":\"Dexxxxx\",\"nihii\":\"1000xxxxx\"}]"

Which indeed has a missing closing parenthese.

This is the code at the server side:

@Path("/yxxxxxxx")
@Produces("application/x-javascript")
public class YellowPagesService implements InitializingBean{

private YPWSClient ypwsClient;

@GET
public JSONWithPadding getClichedMessage(@QueryParam("callback") String callback,          @QueryParam("name_startsWith") String name_startsWith) {

    List<Person> persons = new ArrayList<Person>();
    if(name_startsWith != null && !name_startsWith.equals("")){
        List<Contact> result = ypwsClient.getPersonsStartsWith(name_startsWith).getContact();
        for(Contact c : result){
            if(c.getFirstName() != null){
            Person p = new Person(c.getFirstName(), c.getLastName(), c.getIdentifier());
            persons.add(p);
            }
        }
    }
    JSONWithPadding jsonWithPadding = new JSONWithPadding(new GenericEntity<List<Person>>(persons){}, callback);

    return jsonWithPadding;
}

I am using Jersey 1.12 but I cannot find this issue anywhere logged and I did not find users with the exact same problem, which make me doubt about the cause of this issue. I've tried Genson but to no avail.

Somebody has a clue?

Thanks a lot! Cheers

4

1 回答 1

0

尝试升级到 Genson 0.97,jax-rs 集成代码正在关闭输出流(当它不应该关闭时),因此缺少关闭括号。

于 2013-06-11T08:33:33.757 回答