You need to sign in to do that
Don't have an account?
Steve Berley
deserializing json datetime yields null
I'm trying to deserialize a date/time from a twitter feed into Salesforce and am running into a problem where it always yields a null.
json:
Deserializer from SuperFell's tool
created_at always returns a null, whether I try to capture it as a DateTime, Date or String. I really don't which type I get as long as I get the data since I can always manipulate it later.
Any idea's why?
Obviously this is the compact version relying on the native parser. I've also tried with the involved one and tried to capture the string then convert it within the parser. Still only yields null.
Thanks,
json:
{ "data": [ { "created_at": "2021-06-12T00:00:01.000Z", "id": "1403502310429392901", "text": "She means business \uD83D\uDC69\uD83C\uDFFD⚖️ Gugu Mbatha-Raw is Judge Renslayer in Marvel Studios' #Loki. Stream new episodes of the Original Series every Wednesday on @DisneyPlus. https://t.co/IwpY2eUvwd" } ] }
Deserializer from SuperFell's tool
// Generated by JSON2Apex http://json2apex.herokuapp.com/ public class Twitter_TimelineParser { public class Data { public String created_at; public String id; public String text; } public static Twitter_TimelineParser parse(String json) { return (Twitter_TimelineParser) System.JSON.deserialize(json, Twitter_TimelineParser.class); } }
created_at always returns a null, whether I try to capture it as a DateTime, Date or String. I really don't which type I get as long as I get the data since I can always manipulate it later.
Any idea's why?
Obviously this is the compact version relying on the native parser. I've also tried with the involved one and tried to capture the string then convert it within the parser. Still only yields null.
Thanks,
The wrapper class genearated is wrong. It should be in below format. Data needs to be wrapped in Array so the below line is missing in your wrapper.
public List<Data> data;
In Apex Class you have to use the below code for deserialization.
Thanks,
Maharajan.C