Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //wrapper class
- public class JSON2Apex
- {
- public Datetime DateModifiedUtc{get; set;}
- public List<AgentInfoList> AgentInfoList{get; set;}
- }
- public class AgentInfoList
- {
- public String Username { get; set; }
- public Integer PriorityNumber { get; set; }
- }
- public static JSON2Apex parse(String json)
- {
- return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
- }
- public CalloutAgentList()
- {
- info = (JSON2Apex)parse(helloKitty);
- system.debug('this is the string-->' + info);
- system.debug('this is the string-->' + info.AgentInfoList);
- system.debug('this is the string-->' + info.DateModifiedUtc);
- changeToPst = info.DateModifiedUtc;
- System.debug('This is the Converted Time to PST is ' + changeToPst.format('MM/dd/yyyy HH:mm:ss', 'America/Los_Angeles'));
- newDate = changeToPst.format('MM/dd/yyyy hh:mm aa' , 'America/Los_Angeles');
- }
- static testMethod void testParse() {
- String json = '{"DateModifiedUtc":"2016-09-07T20:12:47.1519119Z","AgentInfoList":[{"Username":"Agent00@gmail.com","PriorityNumber":0},{"Username":"Agent01@gmail.com","PriorityNumber":0},{"Username":"Agent02@gmail.com","PriorityNumber":0},{"Username":"Agent03@gmail.com","PriorityNumber":0},{"Username":"Agent04@gmail.com","PriorityNumber":0},{"Username":"Agent05@gmail.com","PriorityNumber":0}]}';
- JSON2Apex obj = JSON2Apex.parse(json);
- System.assert(obj != null);
- }
- WrapperClassName.JSON2Apex obj = WrapperClassName.JSON2Apex.parse(json);
- public MyClass
- {
- public class JSON2Apex
- {
- //...
- }
- //...
- static JSON2Apex parse(String input)
- {
- //...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement