You need to sign in to do that
Don't have an account?
Populte List<ClassName> from JSON response and show in VF
Hello,
I need a bit help here;
My web service is returning JSON response, e.g..
{"feed":{"row_count":4,"items":[{"msg":"<a class='keyword' href='http://abc.html'>Click to view email1 </a> XXX
<a class='keyword' href='http://abc.html'>send email1</a>.","interestlevel":"High","date":"3/20/2012 10:29:30 PM"},{"msg":"<a class='keyword' href='xyz.html'>Click to view email2</a>XXX<a class='keyword' href='http://xyz.com'>send email2 3</a>.","interestlevel":"Medium","date":"3/20/2012 10:02:33 PM".....}]}}
My requirement is, perform formatting on each value of JSON response (e.g. date, interestlevel values needs to be formatted individually) and send all values individually in one go.
I tried to achieve this using List<String>, but I was unable to perform value formatting as it was passing a single string.
What would be the best possible way to pass JSON response to VF pages?
I just want to show output in VF page like below;
Click to view email1 XXX send email1 updated on 20th March 2012 at 10:29 PM
Click to view email2 XXX send email2 updated on 20th March 2012 at 10:02 PM
.
.
.
.
Can we use functonality like List<ClassName> _objClass = new List<ClassName>();
public class ClassName{
string msg;
string interestlevel;
datetime ddate;
}
but I was not able to achieve it.
How can I achieve the same in Apex and pass it to VF? sample code would be a great help!
Thanks in advance!!
Here is what I use. Then create this service instance in your controller and use the collection of entities however you want.
Thanks for reply.
I've used following code;
public List<clsLiveFeed> objLiveFeed {get; set;}
public class clsLiveFeed {
public string strMessage;
public string strInterest;
public DateTime dtWhen;
}
livef.objLiveFeed = (List<clsLiveFeed>)JSON.deserialize(JSONContent, List<clsLiveFeed>.class);
but it is not converting JSON response to List<clsLiveFeed>. Is there any specific reason?
Also, how do I bind the same to VF page?
below code is also not working;
<apex:dataTable value="{!objLiveFeed }" var="lf">
<apex:column value="{!lf}"/>
</apex:dataTable>
It does not show anything.. Am I missing somthing?
Thanks!