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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Consuming Newtonsoft.Json in X++

(0) ShareShare
ReportReport
Posted on by

Hi All,

Anyone tried to use Newtonsoft.Json in any X++ (AX) project to read Json String?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,996 Most Valuable Professional on at

    Yes, I did. It's even used by Microsoft in the standard application.

    If you have a problem with it, you'll have to tell us what it is.

  • Ariston J. Profile Picture
    on at

    Hi Martin,

    I've follow some post, to create a project in C# then copy and paste .dll to AX folder but it doesn't work and doesn't shown in AOT references.

    Is there any documentation or step and procedure how to successfully use it?

  • Suggested answer
    Martin Dráb Profile Picture
    237,996 Most Valuable Professional on at

    What's the exact version of your AX 2012? My R3 already contains the reference out of the box, so there is no reason for adding it.

    Anyway, the reference doesn't magically add itself just because some file is copied to some folder. If you want to add a reference to AOT, go to the reference node in AOT and add it by yourself.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    If you just compiled the DLL and copied it to the binary folder, that is an incorrect approach.

    If you make a Visual Studio C# Project that has a DLL output, adding it to the AX AOT and setting the deployment setting on the solution to be Server/Client is the correct solution. That will automatically deploy the projects' DLL to the VSAssembly folder and will be available.

  • Ariston J. Profile Picture
    on at

    Hi Martin,

    I'm using AX 2012 R3 CU9.

    If it's already there out of the box, can please share how it consume.

    I need to read my json string call from aif web services and pass all the value in AX.

  • Martin Dráb Profile Picture
    237,996 Most Valuable Professional on at

    JSON is text, therefore "passing it to AX" is exactly the same as with any other string.

    The purpose of the Newtonsoft.Json library is serializing objects to JSON and deserializing JSON strings to objects. It seems that you want to deserialize a JSON string to something, but you didn't tell us what the "something" is.

    A good strategy may be designing a class in C#, deserialize the string to this class and then consuming the class in a strongly-typed manner in AX via .NET Interop.

  • Ariston J. Profile Picture
    on at

    Hi Martin,

    I need to read and pass all data in below Json String to AX Variables.

    "{"_companyId":"USMF","_purchId":"000023","_packingSlipId":"222","_inboundStrings":[{"RecId":"35637332212","LineNumber":"1","ItemId":"VH001","ReceivedQty":"1"},{"RecId":"35637332213","LineNumber":"2","ItemId":"VH001","ReceivedQty":"1"}]}"

    I even tried using,

    RetailCommonWebAPI::getMapFromJsonString(jsonString);

    but it doesn't work, I always received "Client Object must implement IConvertible.".

    When I run my code using Job in AX it's working but when I call it from AIF Web Services got that error.

    By the way it don't have issue if i passed Json string below, which only 1 level I also need to pass all the lines:

    "{"_companyId":"USMF","_purchId":"000023","_packingSlipId":"222"}"

  • Martin Dráb Profile Picture
    237,996 Most Valuable Professional on at

    I'm sorry, but I still don't see any explanation from you to which type you want to deserialize your object. Your code sample mentioned a map - does it mean that you want a map containing an array of other maps? Or what?

    What do you think about the solution I suggested in my previous reply? Wouldn't it be easier and safer? This is still my recommendation, unless you make clear that you can't use it for some reason.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans