Example usage for com.google.gson Gson toString

List of usage examples for com.google.gson Gson toString

Introduction

In this page you can find the example usage for com.google.gson Gson toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.microsoft.projectoxford.emotion.rest.EmotionServiceException.java

License:Open Source License

public EmotionServiceException(Gson errorObject) {
    super(errorObject.toString());
}

From source file:com.microsoft.projectoxford.face.rest.ServiceException.java

License:Open Source License

public ServiceException(Gson errorObject) {
    super(errorObject.toString());
}

From source file:com.microsoft.projectoxford.vision.rest.VisionServiceException.java

License:Open Source License

public VisionServiceException(Gson errorObject) {
    super(errorObject.toString());
}

From source file:org.eclipse.paho.android.service.sample.Listener.java

License:Open Source License

/**
 * Publish the message the user has specified
 *///w  ww .j  a v a 2s .c o  m
private void publish() {
    String topic = ((EditText) connectionDetails.findViewById(R.id.lastWillTopic)).getText().toString();

    ((EditText) connectionDetails.findViewById(R.id.lastWillTopic)).getText().clear();

    String message = ((EditText) connectionDetails.findViewById(R.id.lastWill)).getText().toString();

    ((EditText) connectionDetails.findViewById(R.id.lastWill)).getText().clear();

    RadioGroup radio = (RadioGroup) connectionDetails.findViewById(R.id.qosRadio);
    int checked = radio.getCheckedRadioButtonId();
    int qos = ActivityConstants.defaultQos;

    switch (checked) {
    case R.id.qos0:
        qos = 0;
        break;
    case R.id.qos1:
        qos = 1;
        break;
    case R.id.qos2:
        qos = 2;
        break;
    }

    boolean retained = ((CheckBox) connectionDetails.findViewById(R.id.retained)).isChecked();

    String[] args = new String[2];
    args[0] = message;
    args[1] = topic + ";qos:" + qos + ";retained:" + retained;

    MessageEntity me = new MessageEntity();
    me.title = "Title";
    me.description = "???";
    me.publisher = "";
    me.time = "2016-05-11 15:09:02";
    me.url = "www.baidu.com";
    Gson gson = new Gson();
    gson.toJson(me);
    try {
        Connections.getInstance(context).getConnection(clientHandle).getClient().publish(topic,
                gson.toString().getBytes() /*message.getBytes()*/, qos, retained, null,
                new ActionListener(context, Action.PUBLISH, clientHandle, args));
    } catch (MqttSecurityException e) {
        Log.e(this.getClass().getCanonicalName(),
                "Failed to publish a messged from the client with the handle " + clientHandle, e);
    } catch (MqttException e) {
        Log.e(this.getClass().getCanonicalName(),
                "Failed to publish a messged from the client with the handle " + clientHandle, e);
    }

}

From source file:ws.WaypointsSW.java

@GET
@Produces("application/json")
@Path("Usuario/list")
public String listUsuario() {
    List<Usuario> lista;//from  www.  jav  a 2  s  .  c om

    UsuarioDAO usuarioDAO = new UsuarioDAO();
    lista = usuarioDAO.listar();
    Gson gson = new Gson();
    gson.toString();
    return gson.toJson(lista);
}