Android Setting Name with brackets in body json parameter

Asked

Viewed 66 times

0

I’m having the following problem: I’m using the Android Rest API library https://github.com/excilys/androidannotations/wiki/Rest-API, and I’m trying a post, but the post only accepts a single parameter, which I’m trying to send as an object, and Json expects to receive the following :

public class User(){

  int USER_ID[Id]
  String USER_nome[nome]
}

Since I can’t put brackets as this attribute name on my Object, then how do I send this object?

  • Welcome to the OS. Can you post the JSON that is generated? It would also be interesting for you to post a little more of your code so they can help you better.

1 answer

0

Thulium F. :

These are some of the Body parameters the server is waiting for :

mobile_session[token],
mobile_session[email]

This is a class I’ve created now to illustrate how I’m doing

@Rest(rootUrl = "http://demo2601066.mockable.io/", converters = {MappingJackson2HttpMessageConverter.class,FormHttpMessageConverter.class})
public interface TKSAL {
    @Post(value = "testeJonathan")
    Resposta criarmetodo(Envio envio);
}

This is my Sending Object :

@JsonIdentityReference
public class Envio {
    @JsonProperty("mobile_session[token]")
    Long token;

    @JsonProperty("mobile_session[email]")
    String email;
}

Note that I cannot name the variable mobile_session[token] because the notation does not accept brackets as variable name, so how do I do this ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.