I have my class for serialize variables, but items and fields should be nodes not fields, I need to get this output:
{
"items": [
{
"email": "string",
"fields": [
{
"name": "string",
"value": "string",
}
]
}
]
}
This is the class i have but I dont know how to implement items and fields nodes:
public class DopplerJSONSerializer {
public String name;
public String email;
public String items;
public String fields;
public String upsertSuscribersJSON(String suscriberEmail, String suscName) {
DopplerJSONSerializer suscWrapper = new DopplerJSONSerializer();
suscWrapper.email = suscriberEmail;
suscWrapper.name = suscName;
String listJSON = JSON.serializePretty(suscWrapper, true);
return listJSON;
}
}
Since right now its returning:
{"name":"New Susc", "email":"asd@asd.com"}