How to consume a JSON... GET and POST
This page shows how to consume a JSON (GET and POST)
How to consume a JSON and populates the data in a table
public Response actionIndex() throws IOException, IllegalArgumentException, IllegalAccessException{
Resttest model = new Resttest();
model.load();
ResttestView view = new ResttestView();
String json = Core.httpGet("https://jsonplaceholder.typicode.com/posts", new String[] {}, String.class);
model.setTable_1(new ArrayList<Resttest.Table_1>());
JSONArray aux1 = new JSONArray(json);
for(int i = 0; i < aux1.length(); i ++) {
JSONObject obj = aux1.getJSONObject(i);
Resttest.Table_1 row = new Resttest.Table_1();
row.setQuote(obj.getString("body"));
row.setSequence("" + obj.getInt("id"));
row.setTitulo(obj.getString("title"));
row.setUserid("" + obj.getInt("userId"));
model.getTable_1().add(row);
}
/*----#end-code----*/
view.setModel(model);
return this.renderView(view);
}
How to consume a JSON/POST

Last updated