Note that there are some explanatory texts on larger screens.

plurals
  1. POFill a Java Class with GSon Builder and JSon File
    primarykey
    data
    text
    <p>I want to fill a Java Class with an external JSon File and I works with Gson Builder. But my Java class won´t be filled by the value, which i have declared in the JSon File. What is the problem? Thanks for helping !</p> <p>This is my Json File:</p> <pre><code>{ "tstamp": "2012-11-21 18:00", "id": 123, "publicationList": [ { "id": "1L", "state": "PublicationState.IMMEDIATELY", "channel": "PublicationChannel.TIMETABLE", "startDate": "2001-12-17 18:00", "endDate": "2001-12-17 18:00" }, { "id": "2L", "state": "PublicationState.IMMEDIATELY", "channel": "PublicationChannel.NVS", "startDate": "2001-12-17 18:00", "endDate": "2001-12-17 18:00" }, { "id": "3L", "state": "PublicationState.IMMEDIATELY", "channel": "PublicationChannel.NVS", "startDate": "2001-12-17 18:00", "endDate": "2001-12-17 18:00" } ] } </code></pre> <p>This is my Gson Builder and GSon Instance Creator:</p> <pre><code> Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd HH:mm") .registerTypeAdapter(Publication.class, new PublicationInstanceCreator()).create(); public class PublicationInstanceCreator implements InstanceCreator&lt;PublicationDto&gt; { @Override public PublicationDto createInstance(Type type) { return new PublicationDto(); } } </code></pre> <p>This is the Java Class PublicattionDto:</p> <pre><code>public class PublicationDto{ private static final long serialVersionUID = 1L; private Long id; private PublicationState state = PublicationState.IMMEDIATELY; private PublicationChannel channel; private Date startDate; private Date endDate; //getter and setter methods } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload