Peter Lundgren
Peter Lundgren

Reputation: 1

How do I get natural json notation from app engine?

I have built a REST application with Jersey and didn't succeed in getting natural notation out of JAXB. I simply adapted my GWT application to cast the wrongly transmitted types to what I wanted. I know, not the best solution, but there were no time for something else.

Now that I try to set up cloud endpoints on app engine and get the exact same format which is not what google show in their examples, I suspect that there is something I have missed regarding GAE.

This is what I want from GAE:

{
"anumberprop":123,
"atextprop":"blah",
"anarray":[{"another_no":432}]
}

This is what I actually get:

{
"anumberprop":"123",
"atextprop":"blah",
"anarray":{"another_no":"432"}
}

This causes problems since the client will be a GWT app or a Google Apps Script which parses the JSON internally and this will give a lot of exceptions when the types don't match.

What am I doing wrong?

Best regards, Peter

Upvotes: 0

Views: 223

Answers (1)

saiyr
saiyr

Reputation: 2595

The 432 vs "432" is likely because Cloud Endpoints quotes 64-bit integers so JavaScript clients can use a standard JSON parser without losing precision on those numbers. I'm unable to reproduce the missing array brackets. Can you post your response object?

Upvotes: 1

Related Questions