Last active
April 28, 2019 16:34
-
-
Save jnizet/ab9fce8b8593cf4055550c7a38eceac6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.foo; | |
import java.io.IOException; | |
import java.io.Serializable; | |
import java.util.List; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
public class QnA implements Serializable { | |
private long idQnA; | |
private String question; | |
private List<String> responses; | |
public QnA() { | |
} | |
public QnA(String question, List<String> responses) { | |
this.question = question; | |
this.responses = responses; | |
} | |
public long getIdQnA() { | |
return idQnA; | |
} | |
public void setIdQnA(long idQnA) { | |
this.idQnA = idQnA; | |
} | |
public String getQuestion() { | |
return question; | |
} | |
public void setQuestion(String question) { | |
this.question = question; | |
} | |
public List<String> getResponses() { | |
return responses; | |
} | |
public void setResponses(List<String> responses) { | |
this.responses = responses; | |
} | |
public static void main(String[] args) throws IOException { | |
ObjectMapper om = new ObjectMapper(); | |
String json = "{ \"idQnA\": 205,\n" + | |
" \"question\": \"test\",\n" + | |
" \"responses\": [\"test\",\"test\"]}"; | |
om.readValue(json, QnA.class); // this works fine | |
String json2 = "{ \"idQnA\": 205,\n" + | |
" \"question\": \"test\",\n" + | |
" \"responses\": [{}, {}}"; | |
om.readValue(json2, QnA.class); // this works fine | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment