0

I have a (java.util.List) List returned to the jag. That should be printed as a json .

   var storeForum = Packages.org.wso2.carbon.forum.registry.RegistryForumManager;

   var forum = new storeForum();

   var start = request.getParameter('start');
   var count = request.getParameter('count');

   var array =forum.fetchForumTopics(start,count, tenantDomainsArr, -1234, user.username);

forum.fetchForumTopics method returns

    List<customOjbect> 

How to print it as a json. Didn't find anything useful on net.

Asiri Liyana Arachchi
  • 2,663
  • 5
  • 24
  • 43
  • 1
    You'll have to decide what you want, JSON is a dataformat for strings, an object is a native javascript structure of data, they are in no way the same thing. – adeneo May 01 '14 at 14:53
  • http://stackoverflow.com/questions/558518/how-can-i-serialise-an-object-to-json-in-javascript. Your question appears to be answered here – dops May 01 '14 at 14:54

2 Answers2

1

i'm not quite sure what a jag is - but you can use JSON.stringify() to convert an array of pairs or values into a JSON object

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

JSON.stringify(array) 
eskimomatt
  • 195
  • 9
0

Since this is a java object, can you try this conversion using a java module that can convert the respective Object to JSON?.. You may have to import that module to the .jag (jaggery) file.

Malintha
  • 419
  • 5
  • 13