1

I'm currently trying to determine whether we can replace our company's convoluted XML processing solution (based on XPath) with one based on @SfdcFox's XmlToJson solution.

Unfortunately, the XML we need to parse includes Date and Time as element names, e.g.:

       <RequestedCompletionDateTime>
           <Date>2019-01-28</Date>
           <Time>11:00:09Z</Time>
       </RequestedCompletionDateTime>

Is it possible to use an XML -> Json -> Object solution to parse this document? Or will this prove a blocker issue?

If so, how can we solve this? (I'm thinking maybe we could pre-process the document to rename these element, but I'm not sure that could be done in an efficient way and I'm hoping there would be a more elegant solution.)

  • Is that correct that main issue is that want to use JSON.deserialize into wrapper class, and that does not allow properties named Date and Time? – kurunve Feb 13 at 10:28
  • Apex doesn't allow properties named Date and Time... I would like to use Json.deserialize and unless I misunderstand the code (my experience with deserialize is limited), if I can't create a model with these property names, I shouldn't experience Sfdc's native deserialize to populate values accordingly. – Brian Kessler Feb 13 at 10:51
  • 1
    You are in the right direction. If there are reserved words in your input string and that you try to deserialize those, it will result in error. You will need to replace all such reserved words before deserializing the JSON. – Jayant Das Feb 13 at 16:09
0

I've come to the conclusion that my question may reasonably be closed as a duplicate.

See: How do you deserialize json properties that are reserved words in apex?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.