How to convert arraylist of custom object in to json in javascript
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.
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)
由于这是一个java对象,你可以使用可以将各个对象转换为JSON的java模块来尝试这种转换吗?您可能必须将该模块导入到.jag(jaggery)文件。
链接地址: http://www.djcxy.com/p/46280.html上一篇: Json字符串解析问题