<#assign loanInformation = '{"8":{"loanId":"8","employeeId":"7","loanType":"1","totalAmount":"100000","installmentAmount":"6666.67","remainingBalance":"93333.33","loanTitle":"ELR - EMP739 Umar Naeem (5/1/2024) (House Loan)"},"9":{"loanId":"9","employeeId":"7","loanType":"2","totalAmount":"100000","installmentAmount":"10000","remainingBalance":"90000.0","loanTitle":"ELR-9 (Car Loan)"}}'>
<#assign loanInfoJason = loanInformation?eval_json>
<#list loanInfoJason as loan>
<tr class="bb">
<td align="center" class="br">${loan.loanTitle}</td>
<td align="center" class="br">${loan.installmentAmount}</td>
<td align="center">${loan.remainingBalance}</td>
</tr>
</#list>
这在 freemarker 模板中工作得很好,但是如果
<#assign loanInformation = record.custrecord_dsc_psf_loan_ded_info_json>
无法“?eval_json”字符串并出现以下错误: ---begin-message--- 无效的 JSON 关键字:“Lorem”。应该是以下之一:true、false、null。如果它是一个字符串,那么它必须被引用。错误位置:第 1 行,第 1 列:Lorem ipsum dolor sat amet consectetuer ac orci... ^ ---end-message--- 失败的表达式:==> LoanInformation?eval_json [in template "template" at line 290,第 25 列] ---- FTL 堆栈跟踪(“~”表示与嵌套相关): - 失败于:#assign LoanInfo = LoanInformation... [在模板“template”第 290 行第 5 列]
eval_json 在使用变量时应该能够返回有效的 JSON。
您很可能有一条包含字段
custrecord_dsc_psf_loan_ded_info_json
的记录。
该字段仅包含“lorem ipsum”文本,并且您尝试将其处理为 JSON。当然这是行不通的。
将 JSON 值放入字段中。就像您在模板中硬编码的那样:
{
"8": {
"loanId": "8",
"employeeId": "7",
"loanType": "1",
"totalAmount": "100000",
"installmentAmount": "6666.67",
"remainingBalance": "93333.33",
"loanTitle": "ELR - EMP739 Umar Naeem (5/1/2024) (House Loan)"
},
"9": {
"loanId": "9",
"employeeId": "7",
"loanType": "2",
"totalAmount": "100000",
"installmentAmount": "10000",
"remainingBalance": "90000.0",
"loanTitle": "ELR-9 (Car Loan)"
}
}
而不是
lorem ipsum dolor sit amet