Needs to render json template with array of elements

88 views
Skip to first unread message

Kumar28it

unread,
Aug 11, 2016, 12:48:17 PM8/11/16
to mustache.java
Hi,

I have a requirement to render a array of elements in a json template.
{
"userDetails":{
"name" : "{{name}}",
"age" : "{{age}}",
"address":[
{{#address}}
{
"street": "{{street}}",
"mobile": "{{mobile}}",
},
{{/address}}
]
}
}

Which gives the below output which is a invalid json.
{
"userDetails":{
"name" : "Raj",
"age" : "",
"address":[
{
"street": "SS",
"mobile": "8888888888888",
},
{
"street": "SS",
"mobile": "999999999999",
}, (The template needs to be generate without appending comma in the last element of an array)
]
}
}

Can you help me on this. Thanks in advance.
Reply all
Reply to author
Forward
0 new messages