0

The rest API that I'm calling just returns an integer: 12.

As far as I know that is a valid json although I would have been happier if I could change the response on the server side to something more canonical. Unfortunately that is not an option for me.

Is there a way to use Retrofit to handle that response too?

EDIT

See: this question and the spec

So it seems the new spec allows to use simple string or integer as a json Text

Community
  • 1
  • 1
kingston
  • 11,053
  • 14
  • 62
  • 116
  • please see the updated question – kingston Jun 29 '15 at 15:34
  • Right. That's exactly what I said in my comment: "It's a valid JSON fragment. It is not a valid JSON document." – T.J. Crowder Jun 29 '15 at 15:37
  • what about the part "JSON has been specified more generally in ECMA-404,". Do you mean that ECMA-404 is not used for the json in rest APIs? – kingston Jun 29 '15 at 15:41
  • Looks like they've finally updated the actual definition of JSON to get rid of that confusion: [From the more recent RFC](https://tools.ietf.org/html/rfc7159#section-2): *"A JSON text is a serialized value. Note that certain previous specifications of JSON constrained a JSON text to be an object or an array."* So they did away with that distinction, which is great. A **lot** of tools will be using the old definition, though. – T.J. Crowder Jun 29 '15 at 15:42
  • I **do** wish Crockford would pick one definitive place and stick with it. ECMA or (better) IETF, but not *both*. Or if he insists on both, keep them *both* up to date. But then, crockford and I see things differently in several ways... :-) – T.J. Crowder Jun 29 '15 at 15:43

1 Answers1

0

I found the way to do it: just use Integer as a template parameter for the RestCallback:

new RestCallback<Integer>() {...}
kingston
  • 11,053
  • 14
  • 62
  • 116