[opencms-dev] JSON output

脸谱 afeinet at 163.com
Wed Feb 13 07:55:12 CET 2019



There is another way you can try it:
Jsonpart's element uses variables and does not use a fixed "Title".
<cms:jsonpart element="Title${info.resultIndex}">  ${content.value.Title}  </cms:jsonpart>


Have a look at the background to output a log like this:
Duplicate key for JSON parts:


Because from the output of your output, the parts part gets 3 data, but the List part is overwritten because it is the same KEY ("Title").
In this case, your loop looks like this: Direction3.xml, Direction2.xml, Direction1.xml . . .




--



缘起法实不可思议也。

在 2019-02-13 13:41:55,"Андрей Диканский" <andikk at mail.ru> 写道:
I tried it. I still have "wrong" JSON output:


{"parts":["Title","Title","Title"],"Title":"Title 1"}

It seems that <cms:jsonpart> takes only the last one content element for output.


Среда, 13 февраля 2019, 9:31 +03:00 от 脸谱 <afeinet at 163.com>:


Hi, I have not used the jsonpart tag, but I suggest you use the following code to try to see what the output is.


<cms:contentload collector="allInFolder" param="/service/1/Direction-%(number).xml|Direction" preload="true">

  <cms:contentinfo var="info" />
  <c:if test="${info.resultSize > 0}">
  <cms:contentload>
      <%--  This is itself a loop call. It is not sure which part is decided. --%>
      <cms:contentaccess var="content" /> <%-- This content will change with the loop, so it might be yours Direction1.xml, Direction2.xml, Direction3.xml . . . --%>
      <cms:jsonpart element="Title">  ${content.value.Title}  </cms:jsonpart>
   </cms:contentload>
  </c:if>
 </cms:contentload> 










 

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev






--
Andrew Dikansky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20190213/5c66faf7/attachment.htm>


More information about the opencms-dev mailing list