web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Handle null with FormJsonSerializer X++

(2) ShareShare
ReportReport
Posted on by 49
Hello experts

How to deal with a null value when deserializing an object using FormJsonSerializerin X++, because it throws en error when dealing with a null value
 
Thanks
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    236,184 Most Valuable Professional on at
    Handle null with FormJsonSerializer X++
    Mohamed, your suggested answer doesn't make a good sense to me. Can you please explain where you would put such code and how it'll solve the problem (if you know what the problem is in the first place). It seems to me that we don't yet know the exact problem, therefore suggesting a solution is a bit premature. 
     
    Your code doesn't even seem to be about JSON deserilization at all; you just check whether an object reference is null, but deserialization happens before data from JSON are available in X++ objects.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,311 Super User 2025 Season 2 on at
    Handle null with FormJsonSerializer X++
     
    You must add a condition to avoid desrializing a null object.
     
    if(v != null)
    {
       //your code here
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • Martin Dráb Profile Picture
    236,184 Most Valuable Professional on at
    Handle null with FormJsonSerializer X++
    Please give us more information about your problem. What do you have in JSON (missing property, empty property, null value), how does the target data contract look like, what error are you getting?
     
    Moved from Integration, Dataverse, and general topics forum. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,339

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 824 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 600 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans