there may be many solutions: a recursive function to parse the response, json schema validation … some discussions on this matter here: