Composer - Problem with a List from WebService

Hello everyone!! I have a webService and a backend, y try to a prompt a list of users from the webService.
The connection whit the service go perfect , I use de Var0 and Var1 for the list, the webservice return me the list, and y try to catch with a backendJSP , and this is my code

<%@page language="java" contentType="application/json" pageEncoding="UTF-8"%>
<%!
// Implement this method to execute some server-side logic.
public JSONObject performLogic(JSONObject state, Map<String, String> additionalParams) throws Exception {

String variable[] = {state.getString("Var0")};
String variable2[] = {state.getString("Var1")};
//ArrayList<String> listacod = new ArrayList();
//ArrayList<String> listanom = new ArrayList();
JSONObject result= new JSONObject();
try{
	
    for(int i=0;i<=variable.length;i++){
    	for(int a=0;a<=variable2.length;a++){    
    		String codigo = variable[i];
    		String nombre = variable2[a];
    	result.put("co_usua",codigo);
    	result.put("no_usua",nombre);
    	return result;
    	}
    }
}catch(Exception e){
	e.printStackTrace();
	
}
	   
return result; 
	    
};
%>
<%-- GENERATED: DO NOT REMOVE --%> 
<%@page import="org.json.JSONObject"%>
<%@page import="org.json.JSONException"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@include file="../include/backend.jspf" %>

But the prompt only say’s “Object Object”.
Any idea or similar example? :frowning:

Thanks

Use the looping block:
This is like a “For” in programation.
You can join this block with the prompt block.
You must declare a variable in the looping , for example : VarCount.
And in the prompt block you can put something like this:
‘FileOfSounds/’ + VarArray[VarCount] + ‘.vox’
If the array value is {1,2,3,4}

The result was like

FileOfSound/1.vox
FileOfSound/2.vox
FileOfSound/3.vox
FileOfSound/4.vox

Regards

2 Likes

this kind of thing is easier if you use a program like JSON Viewer (http://jsonviewer.codeplex.com) to see the JSON object.

1 Like