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

Announcements

Community site session details

Community site session details

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

I have a problem that I hope you can help me solve (Read Json File in AL)

(1) ShareShare
ReportReport
Posted on by 4
Hi,,
I have a problem that I hope you can help me solve Read Json File in AL
Error in Postman:
 
Token PASS :
 
 
 
Web Services:
 
 
AL Code : 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
codeunit 50137 "ReadJSONCode"
{
    [ServiceEnabled]
    [Scope('Cloud')]
    procedure ReadJsonTest(JsonObjectText: Text)
    var
        Customer: Record Customer;
        JSONManagement: Codeunit "JSON Management";
        ObjectJSONManagement: Codeunit "JSON Management";
        CodeText: Text;
        CustomerJsonObject: Text;
    begin
        JSONManagement.InitializeObject(JsonObjectText);
        if JSONManagement.GetArrayPropertyValueAsStringByName('Customer', CustomerJsonObject) then begin
            ObjectJSONManagement.InitializeObject(CustomerJsonObject);
 
            Customer.Init();
            ObjectJSONManagement.GetStringPropertyValueByName('No', CodeText);
            Customer.Validate("No.", CopyStr(CodeText.ToUpper(), 1, MaxStrLen(Customer."No.")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Name', CodeText);
            Customer.Validate("Name", CopyStr(CodeText, 1, MaxStrLen(Customer."Name")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Address', CodeText);
            Customer.Validate("Address", CopyStr(CodeText, 1, MaxStrLen(Customer."Address")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Address_2', CodeText);
            Customer.Validate("Address 2", CopyStr(CodeText, 1, MaxStrLen(Customer."Address 2")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('City', CodeText);
            Customer.Validate("City", CopyStr(CodeText, 1, MaxStrLen(Customer.City)));
 
            ObjectJSONManagement.GetStringPropertyValueByName('County', CodeText);
            Customer.Validate("County", CopyStr(CodeText, 1, MaxStrLen(Customer.County)));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Country_Region', CodeText);
            Customer.Validate("Country/Region Code", CopyStr(CodeText, 1, MaxStrLen(Customer."Country/Region Code")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Post_Code', CodeText);
            Customer.Validate("Post Code", CopyStr(CodeText, 1, MaxStrLen(Customer."Post Code")));
 
            Customer.Insert();
 
        end;
    end;
}
I have the same question (0)
  • Gerardo Rentería García Profile Picture
    25,535 Most Valuable Professional on at
  • Suggested answer
    YUN ZHU Profile Picture
    97,557 Super User 2026 Season 1 on at
    Hi, try the following code, I have tested it before and it works without problems.
     
    Thanks.
    ZHU

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 2,185 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,151 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 1,068 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans