What is the best way to get JSON data from a java component. In my java
component I'm compiling JSONObjects and JSONArrays, I would like to return
this data to my velocity script in JSON format, is this possible? 

something like:

{{velocity wiki="false"}}
        #if("$!request.outputSyntax" != '')
          $response.setContentType('application/json')
        #end
        #set($map = [])
        #set ($rightIN =  ${request.rightIN}) 
        #set ($spacenameIN =  ${request.spacenameIN}) 
    #set($disgard =
$map.add($services.g_pagebuilder.userAccessFindPages($spacenameIN,$rightIN
)))
        $jsontool.serialize($map)
{{/velocity}}

and the Java:

          public JSONObject javacomp(String spacenameIN, String rightIN ){
                  JSONObject obj = new JSONObject();
                  try {
                        obj.put("spacenameIN ", spacenameIN );
                        obj.put("rightIN", rightIN );
                } catch (JSONException e) {
                        e.printStackTrace();
                }
                  return obj;
          }

At the end I would like to access this json object as a data return from an
ajax call. Is this possible?

Thanks
Gerrie






--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Returning-JSON-data-from-a-java-component-tp7597700.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to