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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Unable to convert from Microsoft.Dynamics.Nav.Runtime.NavJsonToken to Microsoft.Dynamics.Nav.

(1) ShareShare
ReportReport
Posted on by 153
Hi Guys,
 
I am facing this error.
Error: Unable to convert from Microsoft.Dynamics.Nav.Runtime.NavJsonToken to Microsoft.Dynamics.Nav.Runtime.NavJsonObject.
Is any way to solve this problem.
 
I have the same question (0)
  • Inge M. Bruvik Profile Picture
    1,161 Moderator on at
    Maybe you can share the code that is failing?
    I belive it will be easier to assist you if we can have a look at your code.
  • KK-20050817-0 Profile Picture
    72 on at
     // Iterate over attributes to find currency and rate
                            for i := 1 to xmlAttrCol.Count do begin
                                if xmlAttrCol.Get(i, xmlAttr) then begin
                                    // GPT comment: xmlAttr is initialized from xmlAttrCol.Get(i, xmlAttr)
     
                                    // Check for 'currency' attribute
                                    if xmlAttr.Name = 'currency' then
                                        TargetCurrency := xmlAttr.Value;
     
                                    // Check for 'rate' attribute
                                    if xmlAttr.Name = 'rate' then
                                        if Evaluate(Rate, xmlAttr.Value) then begin
                                            // Check if the target currency is one of our desired target currencies
                                            if TargetCurrencies.Contains(TargetCurrency) then begin
                                                // Insert or update the exchange rate in Currency Exchange Rate table
                                                if CurrencyExchangeRate.Get('EUR', TargetCurrency, Today) then begin
                                                    CurrencyExchangeRate.Validate("Exchange Rate Amount", Rate);
                                                    CurrencyExchangeRate.Modify();
                                                end else begin
                                                    CurrencyExchangeRate.Init();
                                                    CurrencyExchangeRate.Validate("Currency Code", TargetCurrency);
                                                    CurrencyExchangeRate.Validate("Starting Date", Today);
                                                    CurrencyExchangeRate.Validate("Exchange Rate Amount", Rate);
                                                    CurrencyExchangeRate.Insert();
                                                end;
                                                Message('I m inside 2 cu');
                                            end;
                                        end else
                                            Error('Failed to convert rate for %1', TargetCurrency);
                                end;
                            end;
                            XmlElement := gXmlNode.AsXmlElement(); // GPT comment: Initialize XmlElement from gXmlNode
                        end;
  • Suggested answer
    Chavda Dharmendra Profile Picture
    1,000 Super User 2026 Season 1 on at
    I deserialize the JSON file into a JSON token, and then into an array and object.
     
     
    local procedure ShippingAddress(ResponseText: Text)
        var
            JToken: JsonToken;
            JLinesToken: JsonToken;
            JObject: JsonObject;
            ValueObject: JsonObject;
            Jarray: JsonArray;
            i: Integer;
        begin
            JToken.ReadFrom(ResponseText);
            JObject := JToken.AsObject();
            if JObject.SelectToken('$.value', JLinesToken) then begin
                Jarray := JLinesToken.AsArray();
                for i := 0 TO (Jarray.Count - 1) do begin
                    Jarray.Get(i, JLinesToken);
                    ValueObject := JLinesToken.AsObject();
                    SetShipping(ValueObject); //Create Shipping Address
                end;
            end else begin
                SetShipping(JObject);
            end;
        end;

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,857 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,047 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans