I have a JSON feed which I am trying to parse:
{
"test": [
"5",
{
"data": "someData",
"number": "9"
},
{
"data": "someData",
"number": "9"
}
]
}
I am using Jackson to parse the JSON file for me and using annotations:
private ArrayList<Test> test = new ArrayList<Test>();
/**
* #param test the test to set
*/
public void setTest(ArrayList<Test> test) {
this.test = test;
}
And my Test class:
class Test{
private String data= "";
private String number= "";
/**
* #return the data
*/
public String getData() {
return data;
}
/**
* #param data the data to set
*/
public void setData(String data) {
this.data= data;
}
/**
* #return the number
*/
public String getNumber() {
return number;
}
/**
* #param number the number to set
*/
public void setNumber(String number) {
this.number= number;
}
}
If I remove the 5 from my JSON, it works fine. However the 5 will be in the feed so I need a way to parse it. I'm completely new to jackson and annotations in general and after spending most of the day trying to figure this out without any luck, I need some help!
How can I ignore the "5" if its not named, I've tried creating a container class which holds a String and the ArrayList and passed that as a paramater to the setTest method but that didnt work either.
Your Java Test class represents the object, {"data": "someData", "number": "9"}, in the array. You will need to define another Java class to map your Test JSON object, something like
class TopLevel {
private int count;
List<Test> testList = new ArrayList<Test>();
// ...
//setters and getters
}
You can write custom deserializer for this list:
class TestListDeserializer extends JsonDeserializer<List<Test>> {
#Override
public List<Test> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
JsonProcessingException {
List<Test> result = new ArrayList<Test>();
while (jp.nextToken() != JsonToken.END_ARRAY) {
if (jp.getCurrentToken() == JsonToken.START_OBJECT) {
result.add(jp.readValueAs(Test.class));
}
}
return result;
}
}
Now, you have to annotated test property:
#JsonDeserialize(using = TestListDeserializer.class)
private List<Test> test;
You can do it this way
String jsonStr ="{\"test\": [\"5\",{ \"data\": \"someData\", \"number\": \"9\"},
{ \"data\": \"someData\",\"number\": \"10\"}]}";
JSONObject jsonObject =new JSONObject(jsonStr);
String jsonArr = jsonObject.get("test").toString();
JSONArray jsonArray = new JSONArray(jsonArr);
for(int i =1 ;i<jsonArray.length();i++){
JSONObject object = new JSONObject(jsonArray.get(i).toString());
System.out.println(object.get("data")); // use setter instead
System.out.println(object.get("number")); // use setter instead
}
Related
I have JSON response which looks like that:
{
"response":[
"Some number (for example 8091)",
{
"Bunch of primitives inside the first JSONObject"
},
{
"Bunch of primitives inside the second JSONObject"
},
{
"Bunch of primitives inside the third JSONObject"
},
... (and so on)
]
}
So it's an array with first integer element and other elements are JSONObject.
I don't need integer element to be parsed. So how do I handle it using GSON?
I would solve this problem by creating a custom JsonDeserializer and registering it to your Gson instance before parsing. This custom deserializer would be set up to handle both ints and real objects.
First you need to build up a series of model objects to represent the data. Here's a template for what that might look like:
private static class TopLevel {
#SerializedName("response")
private final List<ResponseElement> elements;
private TopLevel() {
this.elements = null;
}
}
private static class ResponseInteger implements ResponseElement {
private final int value;
public ResponseInteger(int value) {
this.value = value;
}
}
private static class ResponseObject implements ResponseElement {
#SerializedName("id")
private final String id;
#SerializedName("text")
private final String text;
private ResponseObject() {
this.id = null;
this.text = null;
}
}
private interface ResponseElement {
// marker interface
}
TopLevel and ResponseObject have private constructors because they are going to let Gson set their fields using reflection, while ResponseInteger has a public constructor because we're going to manually invoke it from our custom deserializer.
Obviously you will have to fill out ResponseObject with the rest of its fields.
The deserializer is relatively simple. The json you posted contains only two kinds of elements, and we'll leverage this. Each time the deserializer is invoked, it checks whether the element is a primitive, and returns a ResponseInteger if so (or a ResponseObject if not).
private static class ResponseElementDeserializer implements JsonDeserializer<ResponseElement> {
#Override
public ResponseElement deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (json.isJsonPrimitive()) {
return new ResponseInteger(json.getAsInt());
}
else {
return context.deserialize(json, ResponseObject.class);
}
}
}
To use this deserializer, you'll have to register it with Gson using the GsonBuilder object.
private static Gson getGson() {
return new GsonBuilder()
.registerTypeAdapter(ResponseElement.class, new ResponseElementDeserializer())
.create();
}
And that's it. Now you can use this Gson object to easily parse TopLevel objects!
public void parseJson() {
TopLevel t = getGson().fromJson(json, TopLevel.class);
for (ResponseElement element : t.elements) {
System.out.println(element);
}
}
8061
[450602: Поздравляем!]
[451700: С реакцией чата и рассуждениями Папани после рипа..]
[451578: Помним...Любим...Скорбим...<br>2107 забирает лучших]
[451371: Земля тебе пухом братишка]
[451332: Доигрался, минус 900 экзов<br><br>R I P]
[451269: ]
[451242: https://www.twitch.tv/arthas подрубка<br><br>evilpapech.ru - скидка 30% на футболки!]
[451217: ]
[451181: или так це жерстко?]
[451108: ]
I used these toString() methods, which I omitted above for brevity:
#Override
public String toString() {
return Integer.toString(value);
}
#Override
public String toString() {
return "[" + id + ": " + text + "]";
}
Try this
Gson gson = new Gson();
// Reading from a file.
Example example = gson.fromJson(new FileReader("D:\\content.json"), Example.class);
POJO
package com.example;
public class Example {
private List<Integer> response = null;
public List<Integer> getResponse() {
return response;
}
public void setResponse(List<Integer> response) {
this.response = response;
}
}
Basically this structure is the wrong format for JSON data.
You need to remove the number, or put this number as a field in the same object like the one below (call ObjectA) and consider this is an array of ObjectA.
Then everything should work well. Try the code below:
public class Response {
#SerializedName("response")
#Expose
public List<ObjectA> objectA = null;
}
public class ObjectA {
#SerializedName("value")
#Expose
public Integer value;
#SerializedName("description")
#Expose
public String description;
}
Response response = new Gson().fromJson(responseString, Response.class);
Please use below ValueObject format which doesn't parse first integer element
public class ResponseVO {
public List<Response> response = new ArrayList();
public class Response {
public final long id;
public final long from_id;
...
}
}
I have the following json object came from remote service:
{
"accumulators": [
{
"balance": "100",
"name": "SMS",
"units": "International SMS"
},
{
"balance": "100",
"name": "VOICE",
"units": "minutes"
},
{
"balance": "50",
"name": "MMS",
"units": "MMS"
}
]
}
I wand to convert map it to the following class depends on the value of object inside that array, so if it is "name": "MMS" then the value must be set to the value of AccumulatorDTO MMS;:
public class BaseDTO {
private AccumulatorDTO messages;
private AccumulatorDTO minutes;
private AccumulatorDTO MMS;
// setters and geters
}
public class AccumulatorDTO {
private int balance;
private String name;
private String units;
// setters and geters
}
Any Idea how to do that using Jackson annotation or custom deserializer?
I can do something like:
AccumulatorDTO[] accumulators = (new ObjectMapper()).convertValue(response.asJson().get("accumulators"), AccumulatorDTO[].class);
Then make iteration over the array and set each property, but really hard to my project structure, I'm looking fo really better solution for a generic purpose (using 1 method for all remote servers, and the deserialization better to be inside DTO somehow, I'm doing some wrapping layer between frontend and backend).
Consider using reflection and name the BaseDTO fields according to the name field in the JSON. Using a #JsonCreator annotated constructor fulfils the requirement of "deserialization better to be inside DTO somehow". E.g.
class BaseDTO {
private AccumulatorDTO sms;
private AccumulatorDTO voice;
private AccumulatorDTO mms;
#JsonCreator
public BaseDTO(#JsonProperty("accumulators") final AccumulatorDTO[] accumulators) {
for (AccumulatorDTO accumulator : accumulators) {
String fieldName = accumulator.getName().toLowerCase();
try {
Field field = getClass().getDeclaredField(fieldName);
field.set(this, accumulator);
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
}
}
}
And deserialise like this:
BaseDTO accumulators = new ObjectMapper().readValue(response.asJson(), BaseDTO.class);
This will initialise the BaseDTO fields according to the array elements and their name. It will let a field be null if it can't match it to an array element and exceptions are thrown.
Jackson doesn't have an annotation to do what you want AFAIK.
The answer provided from #Manos Nikolaidis helped me so much to code my real answer, his answer is good to start, in my cause some of the values contains a spaces or just a non-standard, so I do create a map to map between fields on JSON and the class:
#JsonCreator
public AccountDTO(#JsonProperty("accumulators") final AccumulatorDTO[] accumulators) {
HashMap<String, String> accumulatorsMap = new HashMap<>();
// key is value from JSON, value is field name of class
accumulatorsMap.put("intl sms", "internationalSMS");
accumulatorsMap.put("voice", "minutes");
accumulatorsMap.put("mms", "MMS");
accumulatorsMap.put("voicemessage", "voiceMessages");
accumulatorsMap.put("message", "messages");
for (AccumulatorDTO accumulator : accumulators) {
String fieldName = accumulator.getName().toLowerCase();
try {
Field field = getClass().getDeclaredField(accumulatorsMap.get(fieldName));
field.set(this, accumulator);
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
}
}
I created this Jackson custom deserializer for your BaseDTO class that satisfies your requirement. It looks for the "balance" property and when it found it knows that the following are "name" and "units" so it takes them. Then it switchs on the "name" property and it sets the current AccumulatorDTO to the right field of the BaseDTO class.
public class CustomDeserializer extends StdDeserializer<BaseDTO>{
/**
*
*/
private static final long serialVersionUID = 1L;
public CustomDeserializer(Class<BaseDTO> t) {
super(t);
}
#Override
public BaseDTO deserialize(JsonParser jp, DeserializationContext dc)
throws IOException, JsonProcessingException {
BaseDTO bd = new BaseDTO();
JsonToken currentToken = null;
while ((currentToken = jp.nextValue()) != null) {
if (jp.getCurrentName() != null && jp.getCurrentName().equals("balance"))
{
System.out.println(jp.getCurrentName());
AccumulatorDTO adto = new AccumulatorDTO();
adto.setBalance(Integer.parseInt(jp.getValueAsString()));
currentToken = jp.nextValue();
adto.setName(jp.getValueAsString());
currentToken = jp.nextValue();
adto.setUnits(jp.getValueAsString());
switch (adto.getName().toLowerCase())
{
case "sms":
bd.setMessages(adto);
break;
case "voice":
bd.setMinutes(adto);
break;
case "mms":
bd.setMMS(adto);
break;
}
}
}
return bd;
}
}
I tested it with this simple program:
public class JsonArrayExampleApplication {
public static void main(String[] args) {
//
String json = "{\"accumulators\": [{\"balance\": \"100\",\"name\": \"SMS\",\"units\": \"International SMS\"" +
"},{\"balance\": \"100\",\"name\": \"VOICE\",\"units\": \"minutes\"},{\"balance\": \"50\",\"name\": \"MMS\"," +
"\"units\": \"MMS\"}]}";
ObjectMapper mapper = new ObjectMapper();
SimpleModule mod = new SimpleModule("MyModule");
mod.addDeserializer(BaseDTO.class, new CustomDeserializer(BaseDTO.class));
mapper.registerModule(mod);
BaseDTO bdto = null;
try {
bdto = mapper.readValue(json, BaseDTO.class);
}
catch (IOException e) {
e.printStackTrace();
}
System.out.println("\n--- JSON to JAVA ---\n" + bdto);
}
}
and I got the following output that seems to be ok, because every AccumulatorDTO has been associated to the right property.
--- JSON to JAVA ---
BaseDTO [messages=AccumulatorDTO [balance=100, name=SMS, units=International SMS], minutes=AccumulatorDTO [balance=100, name=VOICE, units=minutes], MMS=AccumulatorDTO [balance=50, name=MMS, units=MMS]]
I have converted a DOM document to json String. However, there are some issues with the way List is mapped in scenario where the List has only one value and List has multiple values.
For ex:
1) After DOM document has been convered to json string, here AlphaStatus List has only with one value:
{
"Gamma": {
.
.
.
.
"AlphaStatuses": {
"AlphaStatus": {
"AlphaHeaderKey": "201612221122273660",
"AlphaLineKey": "201612221122273661",
}
},
"Delta": {
...
}
}
}
2) After DOM document has been convered to json string, here AlphaStatus List has only with multiple values is shown as:
{
"Gamma": {
.
.
.
.
"AlphaStatuses": {
"AlphaStatus": [
{
"AlphaHeaderKey": "201612221122273660",
"AlphaLineKey": "201612221122273661",
},
{
"AlphaHeaderKey": "201612221122273660",
"AlphaLineKey": "201612221122273662",
},
{
"AlphaHeaderKey": "201612221122273660",
"AlphaLineKey": "2016}2221122273663",
}
]
},
"Delta": {
...
}
}
}
I am using the below jackson code to convert xml string to json:
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
Object json = mapper.readValue(jObject.toString(), Object.class);
String output = mapper.writeValueAsString(json);
My question is, how do i ensure that AlphaStatus List is always starting with [{ and ending with }], no matter whether it has only one value or multiple values. How can this be resolved.
It is causing issues in the other system which assumes that AlphaStatus is a List always and expects [{ to be part of the token.
Any help is appreciated.? Or should i use some string utility in such cases to parse AlphaStatus and replace with [{ and }]. How can this be done
First, it seems the line
Object json = mapper.readValue(jObject.toString(), Object.class);
is useless, because you already have an object (jObject) to serialize.
Just use it:
String output = mapper.writeValueAsString(jObject);
For second, it seems your problematic field is of type java.lang.Object, right?
If you as assign a single value to it, it will result in one single Json object:
jObject.setAlphaStatuses(alphaStatus); -> result -> {...}
If you as assign some kind of collection, it will result in a Json array:
jObject.setAlphaStatuses(Arrays.asList(alphaStatus1, alphaStatus2)); -> result -> [{...},{...}]
To avoid that, either always pass a list or (if you can change the definition of the class) make it to a Collection (maybe some List).
Here a small snippet to test:
import java.util.Arrays;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonObjects {
private final static ObjectMapper mapper = new ObjectMapper();
private final static AlphaStatus as1 = new AlphaStatus();
private final static AlphaStatus as2 = new AlphaStatus();
static {
as1.setAlphaHeaderKey("A");
as1.setAlphaLineKey("B");
as2.setAlphaHeaderKey("C");
as2.setAlphaLineKey("D");
}
public static void main(String[] args) throws JsonProcessingException {
final Gamma gamma = new Gamma();
gamma.setAlphaStatuses(Arrays.asList(as1, as2));
System.out.println(mapper.writeValueAsString(gamma));
gamma.setAlphaStatuses(as1);
System.out.println(mapper.writeValueAsString(gamma));
}
static class Gamma {
Object alphaStatuses;
public Object getAlphaStatuses() {
return alphaStatuses;
}
public void setAlphaStatuses(Object alphaStatuses) {
this.alphaStatuses = alphaStatuses;
}
}
static class AlphaStatus {
String alphaHeaderKey;
String alphaLineKey;
public String getAlphaHeaderKey() {
return alphaHeaderKey;
}
public void setAlphaHeaderKey(String alphaHeaderKey) {
this.alphaHeaderKey = alphaHeaderKey;
}
public String getAlphaLineKey() {
return alphaLineKey;
}
public void setAlphaLineKey(String alphaLineKey) {
this.alphaLineKey = alphaLineKey;
}
}
}
And the result (not exactly your result, only for demonstration):
{"alphaStatuses":[{"alphaHeaderKey":"A","alphaLineKey":"B"},{"alphaHeaderKey":"C","alphaLineKey":"D"}]}
{"alphaStatuses":{"alphaHeaderKey":"A","alphaLineKey":"B"}}
#JsonRootName("Gamma")
public class Gamma {
private AlphaStatuses AlphaStatuses;
// getters and setters
}
public class AlphaStatuses {
#JsonProperty("alphaStatus")
private List<AlphaStatus> alphaStatuses;
// getters and setters
}
public class AlphaStatus{
#JsonProperty("alphaHeaderKey")
private String alphaHeaderKey;
#JsonProperty("alphaLineKey")
private String alphaLineKey;
// getters and setters
}
**Test class**:
#Test
public void test() throws Exception {
Gamma gamma=new Gamma();
gamma.setAlphaStatuses(new AlphaStatuses(Arrays.asList(new AlphaStatus("201612221122273660","201612221122273660"))));
ObjectMapper mapper=new ObjectMapper();
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE,true);
String jsonString=mapper.writeValueAsString(gamma);
System.out.println("output "+jsonString);
}
**Output**:
output {"Gamma":{"alphaStatues":{"alphaStatus":[{"alphaHeaderKey":"201612221122273660","alphaLineKey":"201612221122273660"}]}}}
I'm working on a project that communicates with an API using JSON. This is my first attempt at JSON and I've been away from java for a few/several years, so please bear with me.
Here is an idea of what the data looks like:
String 1:
[{
"apicall1":
[{
"thisField":"thisFieldData",
"thatField":"thatFieldData",
"anotherField":"anotherFieldData"
}]
}]
String 2:
[{
"apicall2":
[{
"thatField":"thatFieldData",
"someFieldsAreTheSame":"someFieldsAreTheSameData",
"otherFieldsAreNotTheSame":"otherFieldsAreNotTheSame"
}]
}]
As you can see from my data example, the API returns a JSON string that contains the api used. The array inside contains the data. The API's have a lot of data fields in common but they are unrelated beyond that.
EDIT: There are dozens of these API's types that will need to be handled.
What I am trying to do is create a response class that accepts all of the JSON strings and returns an object containing the appropriate data.
For Example:
Gson gson = new Gson(); //Custom TypeAdapter goes here if needed.
Response apicall2 = gson.fromJson(apicall2String, Response.class);
System.out.println(apicall2.thatField); //Prints thatFieldData
System.out.println(apicall2.someFieldsAreTheSame); //Prints someFieldsAreTheSameData
System.out.println(apicall2.otherFieldsAreNotTheSame); //Prints otherFieldsAreNotTheSameData
This is where I am lost. Here is what I have so far. I think I need to use a TypeAdapter here but haven't been able to figure how to apply that to my case.
public class Response { //Change to TypeAdapter possibly?
}
public class apicall1 {
String thisField;
String thatField;
String anotherField;
}
public class apicall2 {
String thatField;
String someFieldsAreTheSame;
String otherFieldsAreNotTheSame;
}
You can use Gson's TypeToken class to deserialize json into object. Below is an example:
JSON:
[{ "apicall1":
[{
"thisField":"thisFieldData",
"thatField":"thatFieldData",
"anotherField":"anotherFieldData"
}]
}]
Model:
class Response{
private List<Result> apicall1;
class Result{
private String thisField;
private String thatField;
private String anotherField;
public String getThisField() {
return thisField;
}
public void setThisField(String thisField) {
this.thisField = thisField;
}
public String getThatField() {
return thatField;
}
public void setThatField(String thatField) {
this.thatField = thatField;
}
public String getAnotherField() {
return anotherField;
}
public void setAnotherField(String anotherField) {
this.anotherField = anotherField;
}
}
public List<Result> getApicall1() {
return apicall1;
}
public void setApicall1(List<Result> apicall1) {
this.apicall1 = apicall1;
}
}
Converter:
public static void main(String[] args) {
String response = "[{ \"apicall1\": [{ \"thisField\":\"thisFieldData\", \"thatField\":\"thatFieldData\", \"anotherField\":\"anotherFieldData\" }]}]";
Gson gson = new Gson();
List<Response> responses = gson.fromJson(response, new TypeToken<List<Response>>(){}.getType());
System.out.println(responses.get(0).getApicall1().get(0).getThisField());
}
I don't know if you want both adapters in one class. Might not be the best OOP design.
To achieve it you would need to do something like so:
public class DoublyTypeAdapter implements JsonDeserializer<ApiCallTypeParent>
{
Gson gson = new Gson();
#Override
public ApiCallTypeParent deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext)
throws JsonParseException {
JsonObject json = jsonElement.getAsJsonObject();
ApiCallTypeParent desrializeIntoMe;
// Detect which type to implement
if(apiTypeOne(type) {
desrializeIntoMe = new TypeOne();
} else {
desrializeIntoMe = new TypeTwo();
}
for (Map.Entry<String, JsonElement> entry : json.entrySet())
{
switch(entry.getKey()){
case "thisField":
desrializeIntoMe.setThisField(entry.getValue().getAsString());
break;
......
default: // We don't care
break;
}
}
return desrializeIntoMe ;
}
}
Using this as a reference I have described the structure of my Json data and can grab the information as needed until I get to nest records and arrays.
Parsing a complex Json Object using GSON in Java
However my JSON data is nested several times over. For example;
{
"meetings": [
{
"meetingName": "GaryVon",
"location": "USA",
"meetingType": "P",
"meetingDate": "2016-03-25",
"weatherCondition": "FINE",
"showCode": {
"meetingCode": "A",
"scheduledType": "R"
},
"venueType": "ANI",
"showPools": [
{
"showProduct": "GaryVon",
"showStatus": "Open",
}
]
}
]
}
I have my wrapper and classes describing the format of the json data. Each class in a new java file.
public class meetingContainer {
public List<meetings> meetings;
}
Top level class
public class meetings {
private String meetingName;
private String location;
private String meetingType;
private String meetingDate;
private String weatherCondition;
private ShowCode showCode;
private String venueType;
private ShowPools[] showPools;
public String getMeetingName() { return meetingName; }
public String getLocation() { return location; }
public String getMeetingType() { return meetingType; }
public String getMeetingDate() { return meetingDate; }
public String getWeatherCondition() { return weatherCondition; }
public ShowCode getShowCode() { return showCode; }
public String getVenueType() { return venueType; }
public ShowPools[] getShowPools() { return showPools; }
}
2nd Level class
public class ShowCode {
private String meetingCode;
private String scheduledType;
public String getMeetingCode() { return meetingCode; }
public String getScheduledType() { return scheduledType; }
}
2nd Level Class
public class ShowPools {
private String showProduct;
private String showStatus;
public String getShowProduct() { return showProduct; }
public String getShowStatus() { return showStatus; }
}
I then try to parse it and grab the data which works fine until I get into nested arrays/records
Gson g = new Gson();
meetingContainer mc = g.fromJson(jsonMeetingsString, meetingContainer.class);
for(meetings m: mc.meetings){
System.out.println(m.getMeetingName()); //Result = "GaryVon"
System.out.println(m.getLocation()); //Result = "USA"
System.out.println(m.getmeetingType()); //Result = "P"
System.out.println(m.getShowCode()); //Result = "packagename.ShowCode#210366b4"
}
My question is how to I declare nested arrays/records and then call those methods from different classes i.e. Call the methods in showcode and showpools. The other post did not say how. Sorry if this is a simple answer as I'm new to java.
m.getShowCode()
This returns a reference of type ShowCode, to access inner values use the getters, for example :
m.getShowCode().getMeetingCode()
You should use a list for showPools
private List<ShowPools> showPools;
Your provided JSON string is invalid. It has one extra , -
{
"showProduct": "GaryVon",
"showStatus": "Open",
^
Answer for your question you asked in comment : m.getShowCode().getShowProduct() is invalid since showCode node has only two attributes meetingCode and scheduledType.
below code is listing all values of JSON. Let me know if it not covers your question
Gson g = new Gson();
meetingContainer mc = g.fromJson(jsonMeetingsString,
meetingContainer.class);
for (meetings m : mc.meetings) {
System.out.println("meetingName: " + m.getMeetingName());
System.out.println("location: "+ m.getLocation());
System.out.println("meetingType: "+ m.getMeetingType());
System.out.println("meetingDate: "+ m.getMeetingDate());
System.out.println("weatherConditio: "+ m.getWeatherCondition());
System.out.println("showCode->meetingCode: "+ m.getShowCode().getMeetingCode());
System.out.println("showCode->scheduledType: "+ m.getShowCode().getScheduledType());
System.out.println("venueType: "+ m.getVenueType());
for(ShowPools showPool : m.getShowPools()){
System.out.println("showPools->showProduct: "+ showPool.getShowProduct());
System.out.println("showPools->showStatus: "+ showPool.getShowStatus());
}
}
Output:
meetingName: GaryVon
location: USA
meetingType: P
meetingDate: 2016-03-25
weatherConditio: FINE
showCode->meetingCode: A
showCode->scheduledType: R
venueType: ANI
showPools->showProduct: GaryVon
showPools->showStatus: Open