I'm trying to deserialize the following JSON which I'm obtaning from the Google Cloud Platform Translation API:
{
"data": {
"detections": [
[
{
"confidence": 0.394001841545105,
"isReliable": false,
"language": "en"
}
],
[
{
"confidence": 0.25323036313056946,
"isReliable": false,
"language": "es"
}
]
]
}
}
But I don't know how to make the model. I've tried this:
private class DetectionModel {
public Detection[] detections;
}
private class Detection {
public String language;
public Boolean isReliable;
public Decimal confidence;
}
In order to later do:
DetectionModel model = (DetectionModel) JSON.deserialize(responseBody, DetectionModel.class);
model.detections[0].language;
But it's not exactly right. Can you guys help me define the DetectionModel
correctly? I'm not sure how to do it since the list of "detections" doesn't have a property name.
The Documentation would be here.