How to display JSON data with Jelly

Artur Poswiata1
Kilo Contributor

Hello,

I want to display JSON data in UI Page.
The JSON looks like this:
find_real_file.png

For so long I wrote this

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate>
    
    var r = 'Outbound REST Message';
    var request = new sn_ws.RESTMessageV2(r, 'get');
    var response = request.execute();
    var responseBody = response.getBody();
    
    var obj = JSON.parse(responseBody);
    
</g:evaluate>
    
<j:forEach var = "jvar_get" items = "${obj.result}">
    <p> ${jvar_get} </p>
    </j:forEach>    
</j:jelly>

 

I receive this.

[object Object]

[object Object]

[object Object]

[object Object]

[object Object]

How I can get access to every single one names ?

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi,

you can access the data like this.

<j:forEach var = "jvar_get" items = "${obj.result}">
    <p> ${jvar_get.name} </p>
    </j:forEach>    
</j:jelly>

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

View solution in original post

2 REPLIES 2

Saud1
Mega Guru

Hello Artur,

Try not parsing the responseBody into a JavaScript object. Like this:

var obj = responseBody;

asifnoor
Kilo Patron

Hi,

you can access the data like this.

<j:forEach var = "jvar_get" items = "${obj.result}">
    <p> ${jvar_get.name} </p>
    </j:forEach>    
</j:jelly>

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP