简体   繁体   中英

Remove quotations from MVEL @foreach over string array

I am using the @foreach Orb notation in MVEL to iterate over a string array.

someArrayPartOfAJSONObject = ["Item 1", "Item 2"]

<ul>
  @foreach{item: someArrayPartOfAJSONObject}
  <li>@{item}</li>
</ul>

But what I'm seeing in the renders HTML is:

  • "Item 1"
  • "Item 2"

When I would be expecting those to render without the quotations. The data that's passed in is part of a JSON object from a backend call, so there's not much else to that object. Am I missing some important fundamental of MVEL?

I was able to figure this out. By using the replace method I was able to remove the quotations from the strings.

<ul>
  @foreach{item: someArrayPartOfAJSONObject}
  <li>${replace(item,"\"","")}</li>
</ul>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM