<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>I've modified my code with for each loop. </p>
<p><br>
</p>
<div><cms:contentload collector="allInFolder" param="/service/1/Direction-%(number).xml|Direction" preload="true"><br>
</div>
<div>  <cms:contentinfo var="info" /></div>
<div>  <c:if test="${info.resultSize > 0}"></div>
<div>  Results<br><br>
</div>
<div>  <cms:contentload></div>
<div>     <cms:contentaccess var="content" /></div>
<div><span style="white-space:pre"></span>  <c:forEach var="teaser" items="${content.valueList['Title']}"></div>
<div>      <cms:jsonpart element="Title">  ${teaser}  </cms:jsonpart><br></div>
<div>     </c:forEach><br>
</div>
<div>   </cms:contentload></div>
<div>  </c:if></div>
<div> </cms:contentload> <br>
</div>
<div><br>
</div>
<div>In <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">/service/1/ I have 3 files: <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Direction1.xml, <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Direction2</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">.xml</span>, <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Direction3</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">.xml</span></span></span><br>
</div>
<p><br>
</p>
<p>But in JSON output I have content of the last item of the loop only:<br>
</p>
<pre style="overflow-wrap: break-word; white-space: pre-wrap;">{"parts":["Title","Title","Title"],"Title":"Title 1"}<br></pre>
<p>​I expect to see in JSON output something like this:<br>
</p>
<pre style="font-size: 16px; overflow-wrap: break-word; white-space: pre-wrap;">{"parts":["Title","Title","Title"],
"Title":"Title 1", 
"Title":"Title 2<span style="font-family: Calibri, Arial, Helvetica, sans-serif;">", 
</span>"Title":"Title 3<span style="font-family: Calibri, Arial, Helvetica, sans-serif;">"</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif;">}</span></pre>
<p>Can I achive it in OpenCMS with <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">jsonpart</span>​ tag?<br>
</p>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
Andrew Dikansky<br>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"><br>
</div>
</div>
</div>
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> Диканский Андрей Юрьевич<br>
<b>Отправлено:</b> 7 февраля 2019 г. 10:29<br>
<b>Кому:</b> opencms-dev@opencms.org<br>
<b>Тема:</b> JSON output</font>
<div> </div>
</div>
<div>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hello</p>
<p>I’m trying to use <cms:jsonpart> tag to provide  convertations parts of my HTML to JSON.</p>
<p>I edited a formatter for the default resource type by adding <span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px; background-color:rgb(255,255,255)"><cms:jsonpart></span>.<br>
</p>
<div><br>
</div>
<div><cms:formatter var="content"></div>
<div><span style="white-space:pre"></span><div class="margin-bottom-30"></div>
<div><span style="white-space:pre"></span><div class="headline"></div>
<div><span style="white-space:pre"></span><cms:jsonpart element="title"><h3 ${content.rdfa.Title}>${content.value.Title}</h3></cms:jsonpart></div>
<div><span style="white-space:pre"></span></div></div>
<div><span style="white-space:pre"></span><div class="row"></div>
<div><span style="white-space:pre"></span><c:if test="${content.value.Image.exists}"></div>
<div><span style="white-space:pre"></span><div class="col-md-4 col-sm-2 hidden-xs"></div>
<div><span style="white-space:pre"></span><div class="thumbnail-kenburn"></div>
<div><span style="white-space:pre"></span><div class="overflow-hidden"></div>
<div><span style="white-space:pre"></span><cms:img src="${content.value.Image}" scaleColor="transparent"</div>
<div><span style="white-space:pre"></span>width="400" scaleType="0" noDim="true" cssclass="img-responsive" /></div>
<div><span style="white-space:pre"></span></div></div>
<div><span style="white-space:pre"></span></div></div>
<div><span style="white-space:pre"></span></div></div>
<div><span style="white-space:pre"></span></c:if></div>
<div><span style="white-space:pre"></span><div class="${content.value.Image.exists ? 'col-md-8 col-sm-10 col-xs-12' : 'col-xs-12' }"></div>
<div><span style="white-space:pre"></span></div>
<div><span style="white-space:pre"></span><div ${content.rdfa.Text}><cms:jsonpart element="description">${content.value.Text}</cms:jsonpart></div></div>
<div><span style="white-space:pre"></span><c:if test="${content.value.Link.exists}"></div>
<div><span style="white-space:pre"></span><p></div>
<div><span style="white-space:pre"></span><a class="btn-u btn-u-small"</div>
<div><span style="white-space:pre"></span>href="<cms:link>${content.value.Link}</cms:link>">${paragraph.value.Link}</a></div>
<div><span style="white-space:pre"></span></p></div>
<div><span style="white-space:pre"></span></c:if></div>
<div><span style="white-space:pre"></span></div></div>
<div><span style="white-space:pre"></span></div></div>
<div><span style="white-space:pre"></span></div></div>
<div></cms:formatter><br>
</div>
<p><br>
</p>
The problem is that I have several content elements  of this formater on one page, so json output contains only the last one element content.<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">What should I change in my jsp to provide all content of all elements to json output? Where should I make it? In template main.jsp?<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">Andrew Dikansky<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"><br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>