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.

2
  • 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. Commented May 1, 2014 at 14:53
  • stackoverflow.com/questions/558518/…. Your question appears to be answered here Commented May 1, 2014 at 14:54

2 Answers 2

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) 
Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't work. It only gives "{}" as the output even though returned list is not empty.
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.

1 Comment

That'll work.But I wonder if there's a way to do this conversion with out having to import any java module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.