Questions tagged as 'gson'

0
answers

How to find where is the circular reference in GSON?

Imagine that I have these classes: public class A { private B b; } public class B { private A a; } And then I have this: A a = new A(); B b = new B(); a.b = b; b.a = a; Gson gson = new Gson(); String x = gson.toJson(a); The re...
asked by 21.03.2017 / 14:56
1
answer

Gson to Java - Map

I need to pass these values from a json file to a java class, the Json file is of this type: { "id":1, "name":"Gold", "description":"Shiny!", "spriteId":1, "consumable":true, "effectsId":[1]...
asked by 23.10.2015 / 03:00
1
answer

How to deserialize a list with items of type {"key": "value"}?

I need to deserialize a JSON, but I can not map the enumerated object. Follow JSON: { "list": [ { "1": "Bola" }, { "2": "Quadrado" }, { "3": "Retangulo" } ], "code": 0, "success": true }...
asked by 11.08.2016 / 01:08
2
answers

String deserialization

I got Retrofit the Drivers field from the following json: { "Drivers": [ { "DriverID": 0, "Latitude": -23.642276336, "Longitude": -46.634615118 }, { "DriverID": 1, "Latitude": -23.64227916, "Lo...
asked by 22.01.2016 / 16:22
1
answer

How to deserialize JSON using Gson with generic list?

I need to deserialize JSON to a generic list, but I'm having an error that I believe to be in the conversion: Method call: AtualizarJSON at = (AtualizarJSON) DeserializaConsulta(AtualizarJSON.class, resultadoJSON); Method: private <...
asked by 18.11.2014 / 00:48
1
answer

How to transform this Json into an ArrayList of objects?

I'm working on a project where I'm doing a query in the database and need to return a list of database users to be listed in my application. I have the following line Json (returned by the server): {"id": 1, "nome": Raphael, "sexo": M}{"id"...
asked by 08.10.2016 / 08:45
1
answer

How to check if a given field / value exists in the JSON document?

{ "timestamp":"2018-10-08T16:58:38.949Z", "dataFrame":"QQ==", "fcnt":15, "freq":902500000, "port":12, "rssi":-69, "snr":10, "sf_used":10, "session_id":"f41e10e8-1c73-499c-8ad7-4cbcd54c8ebd", "gtw_info":[{ "gtw_id":"000000000b0319a3", "rss...
asked by 09.10.2018 / 17:49
1
answer

Send an object using Gson

I have the following problem: I need to send an object to my web-service, however, it is not feasible to use JSONStringer because my class has many fields. What would be the best way to solve this problem? I used the following method but it did...
asked by 07.04.2015 / 13:28
1
answer

How to transoform JSON into an array of objects of a specific class, and does this class have compound attributes?

I encountered the following problem when trying to transform a String JSON into object list. I have the following situation: I have a Response class that has some attributes, among them a list of " Post ", an object of cla...
asked by 17.05.2015 / 05:09
1
answer

Error Building Json of an Object retrieved by Hibernate

Error constructing Json from an object retrieved by Hibernate. session.getTransaction().begin(); ArrayList<Cliente> lista = new ArrayList<>(session.createCriteria(Cliente.class).list()); String json = new Gson().toJson(list...
asked by 13.11.2014 / 15:08