Model view controller 在Freemarketnet中格式化数据

Model view controller 在Freemarketnet中格式化数据,model-view-controller,freemarker,Model View Controller,Freemarker,我使用freemarketnet以适当的内容替换宏。为此,我将json对象从mvc控制器发送到视图。在视图中,我想以对象格式读取json 这是我的代码 <#import "../Shared/Master.ftl" as layout /> <#assign TitleContent in layout> Home Page </#assign> <#assign Recipient = controlle

我使用freemarketnet以适当的内容替换宏。为此,我将json对象从mvc控制器发送到视图。在视图中,我想以对象格式读取json

这是我的代码

    <#import "../Shared/Master.ftl" as layout /> 
    <#assign TitleContent in layout>
    Home Page
    </#assign>  
    <#assign Recipient =  controller.ViewData.data> 
    ${Recipient} 
现在,视图渲染为

    {'contact':{ 'cx_outstandingamountid':{'cx_outstandingamount':'ytest' } } }
但我想渲染为“ytest”。为了这个我试过了

${Recipient.contact.cx_outstandingamountid.cx_outstandingamount}

但它没有起作用。有人能帮我吗?

我们需要使用eval来解析freemarker中的json。参考


${Recipient.contact.acsi_outstandingamountid.acsi_outstandingamount}

错误消息是什么,或者它到底是如何工作的?@ddekany在视图中,json输出是字符串。我想把它作为对象,这样我就可以给出如下${Recipient.contact.cx_outstandingamountid.cx_outstandingamount}
${Recipient.contact.cx_outstandingamountid.cx_outstandingamount}
<#assign recip=controller.ViewData.data>
<#assign Recipient = recip?eval>    
${Recipient.contact.acsi_outstandingamountid.acsi_outstandingamount}