Skip to main content

Notifications

Announcements

No record found.

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 2
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;
}
  • Suggested answer
    YUN ZHU Profile Picture
    81,912 Super User 2025 Season 1 on at
    I have a problem that I hope you can help me solve (Read Json File in AL)
    Hi, try the following code, I have tested it before and it works without problems.
     
    Thanks.
    ZHU
  • Gerardo Rentería García Profile Picture
    17,800 Most Valuable Professional on at
    I have a problem that I hope you can help me solve (Read Json File in AL)

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,351 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,029 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans