Difference in Template Rendering Between Velocity 2.3 and 2.4.1 for Map with List
Mergu Ravi <[email protected]> Tue, 22 Jul 2025 19:08:38 +0530
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <CAK+i-4KgWuB336AkOz6sk5rWpjHEDn7uiVYnARBuauDiqdgw8g__9828.47523862205$1753191572$gmane$org@mail.gmail.com> |
--000000000000583d99063a84b663
Content-Type: multipart/alternative; boundary="000000000000583d97063a84b662"
--000000000000583d97063a84b662
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Dear Velocity Team,
I hope this message finds you well.
I'm currently using Apache Velocity in my Java application, and I noticed a
behavioral difference in template rendering when upgrading from version
*2.3* to *2.4.1*.
Template:
{
"students" : $student.values
}
Sample JSON (studentData):
{
"student": {
"values": [
{ "id": 1, "name": "Alice", "age": 20, "grade": "A" },
{ "id": 2, "name": "Bob", "age": 21, "grade": "B" }
]
}
}
Output in Velocity 2.3:
{
"students" : [{id=3D1, name=3DAlice, age=3D20, grade=3DA}, {id=3D2, name=
=3DBob,
age=3D21, grade=3DB}]
}
Output in Velocity 2.4.1:
{
"students" : [[{id=3D1, name=3DAlice, age=3D20, grade=3DA}, {id=3D2, name=
=3DBob,
age=3D21, grade=3DB}]]
}
Concern:
In *2.4.1*, the result includes an extra set of brackets, indicating that
Velocity is now treating the .values object as a list containing a list
instead of a list itself.
This change in behavior breaks backward compatibility in my use case. I'm
unsure if this change was intentional or a regression.
Screenshots:
I=E2=80=99ve attached screenshots of the same Java code executed with both =
versions:
-
*velocity-2.3*
- [image: Screenshot from 2025-07-22 18-38-28.png]
-
*velocity-2.4.1*
- [image: Screenshot from 2025-07-22 18-39-00.png]
Request:
Could you please clarify if this is:
-
An intended change in how Velocity handles map values, or
-
A bug introduced in the recent release?
Additionally, if there's a recommended workaround or best practice for
handling this in 2.4.1, I=E2=80=99d greatly appreciate the guidance.
Thanks for maintaining such a helpful project!
Best regards,
*Ravi Mergu*
------------------------------
--000000000000583d97063a84b662
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><p>Dear Velocity Team,</p><p>I hope this message finds you=
well.</p>
<p>I'm currently using Apache Velocity in my Java application, and I no=
ticed a behavioral difference in template rendering when upgrading from ver=
sion <strong>2.3</strong> to <strong>2.4.1</strong>.</p><h3>Template:</h3>
<pre><code class=3D"gmail-language-velocity">{
"students" : $student.values
}
</code></pre>
<h3>Sample JSON (<code>studentData</code>):</h3>
<pre><code class=3D"gmail-language-json">{
"student": {
"values": [
{ "id": 1, "name": "Alice", "age&q=
uot;: 20, "grade": "A" },
{ "id": 2, "name": "Bob", "age&quo=
t;: 21, "grade": "B" }
]
}
}
</code></pre>
<h3>Output in Velocity 2.3:</h3>
<pre><code class=3D"gmail-language-json">{
"students" : [{id=3D1, name=3DAlice, age=3D20, grade=3DA}, {id=
=3D2, name=3DBob, age=3D21, grade=3DB}]
}
</code></pre>
<h3>Output in Velocity 2.4.1:</h3>
<pre><code class=3D"gmail-language-json">{
"students" : [[{id=3D1, name=3DAlice, age=3D20, grade=3DA}, {id=
=3D2, name=3DBob, age=3D21, grade=3DB}]]
}
</code></pre>
<h3>Concern:</h3>
<p>In <strong>2.4.1</strong>, the result includes an extra set of brackets,=
indicating that Velocity is now treating the <code>.values</code> object a=
s a list containing a list instead of a list itself.</p>
<p>This change in behavior breaks backward compatibility in my use case. I&=
#39;m unsure if this change was intentional or a regression.</p>
<h3>Screenshots:</h3>
<p>I=E2=80=99ve attached screenshots of the same Java code executed with bo=
th versions:</p>
<ul><li>
<p><code><b><font size=3D"4">velocity-2.3</font></b></code></p></li><li><im=
g src=3D"cid:ii_mdekqo901" alt=3D"Screenshot from 2025-07-22 18-38-28.png" =
width=3D"554" height=3D"470"><br><br></li><li>
<p><code><font size=3D"4"><b>velocity-2.4.1</b></font></code></p></li><li><=
img src=3D"cid:ii_mdekq5uk0" alt=3D"Screenshot from 2025-07-22 18-39-00.png=
" width=3D"554" height=3D"470"><br><br></li></ul>
<h3>Request:</h3>
<p>Could you please clarify if this is:</p>
<ul><li>
<p>An intended change in how Velocity handles map values, or</p>
</li><li>
<p>A bug introduced in the recent release?</p>
</li></ul>
<p>Additionally, if there's a recommended workaround or best practice f=
or handling this in 2.4.1, I=E2=80=99d greatly appreciate the guidance.</p>
<p>Thanks for maintaining such a helpful project!</p>
<p>Best regards,<br><strong>Ravi Mergu</strong></p>
<hr></div>
--000000000000583d97063a84b662--
--000000000000583d99063a84b663--