Hi, Readers.
The public preview for Dynamics 365 Business Central 2025 release wave 1 (BC26) is available. Learn more: Link.
I will continue to test and share some new features that I hope will be helpful.
Overloaded JsonObject data type GetValue method:
Business value:
To work more efficiently with JSON in AL, we have improved the AL API for accessing JSON data with a new set of overloaded JsonObject GetValue methods.Feature details:
We have improved the API for accessing JSON data with a new set of methods that will avoid always having to read data through a JsonToken.
For JsonObject instances, we have added:value := GetBoolean(Key: Text [; DefaultIfNotFound: Boolean]) value := GetByte(Key: Text [; DefaultIfNotFound: Boolean]) value := GetChar(Key: Text [; DefaultIfNotFound: Boolean]) value := GetInteger(Key: Text [; DefaultIfNotFound: Boolean]) value := GetBigInteger(Key: Text [; DefaultIfNotFound: Boolean]) value := GetDecimal(Key: Text [; DefaultIfNotFound: Boolean]) value := GetOption(Key: Text [; DefaultIfNotFound: Boolean]) value := GetDateTime(Key: Text [; DefaultIfNotFound: Boolean]) value := GetDate(Key: Text [; DefaultIfNotFound: Boolean]) value := GetTime(Key: Text [; DefaultIfNotFound: Boolean]) value := GetDuration(Key: Text [; DefaultIfNotFound: Boolean]) value := GetText(Key: Text [; DefaultIfNotFound: Boolean]) value := GetArray(Key: Text [; DefaultIfNotFound: Boolean]) value := GetObject(Key: Text [; DefaultIfNotFound: Boolean])
For JsonArray instances, we have added:
https://learn.microsoft.com/en-us/dynamics365/release-plan/2025wave1/smb/dynamics365-business-central/search-navigate-use-app-symbols-as-context-github-copilot?wt.mc_id=DX-MVP-5004336value := GetBoolean(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetByte(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetChar(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetInteger(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetBigInteger(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetDecimal(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetOption(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetDateTime(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetDate(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetTime(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetDuration(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetText(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetArray(Index: Integer [; DefaultIfNotFound: Boolean]) value := GetObject(Index: Integer [; DefaultIfNtFound: Boolean])
This is also mentioned in AL Language extension changelog Version 15.0:
We have improved the API for accessing JSON data with a new set of methods that will avoid always to read data through a JsonToken.
https://marketplace.visualstudio.com/items/ms-dynamics-smb.al/changelog

Let’s look at some concrete examples.
In Dynamics 365 Business Central: Can we get all environments within BC via AL (Not in Admin Center), we briefly discussed how to get all BC environments through the API.
Test endpoint:
https://api.businesscentral.dynamics.com/admin/v2.3/applications/businesscentral/environments
Response:

{
"value": [
{
"friendlyName": "2qcj3x-SandboxUS",
"type": "Sandbox",
"name": "SandboxUS",
"countryCode": "US",
"applicationFamily": "BusinessCentral",
"aadTenantId": "7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62",
"applicationVersion": "25.3.28755.30175",
"status": "Active",
"webClientLoginUrl": "https://businesscentral.dynamics.com/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/SandboxUS",
"webServiceUrl": "https://api.businesscentral.dynamics.com/v2.0/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/SandboxUS",
"locationName": "East US",
"platformVersion": "25.2",
"databaseSize": {
"value": 425984.0,
"unit": "Byte"
},
"ringName": "Production",
"appInsightsKey": ""
},
{
"friendlyName": "2qcj3x",
"type": "Production",
"name": "Production",
"countryCode": "US",
"applicationFamily": "BusinessCentral",
"aadTenantId": "7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62",
"applicationVersion": "25.0.23364.30130",
"status": "Active",
"webClientLoginUrl": "https://businesscentral.dynamics.com/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/Production",
"webServiceUrl": "https://api.businesscentral.dynamics.com/v2.0/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/Production",
"locationName": "South Central US",
"platformVersion": "25.0",
"databaseSize": {
"value": 425984.0,
"unit": "Byte"
},
"ringName": "Production",
"appInsightsKey": ""
},
{
"friendlyName": "2qcj3x-Sandbox254",
"type": "Sandbox",
"name": "Sandbox254",
"countryCode": "JP",
"applicationFamily": "BusinessCentral",
"aadTenantId": "7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62",
"applicationVersion": "25.4.29661.30648",
"status": "Active",
"webClientLoginUrl": "https://businesscentral.dynamics.com/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/Sandbox254",
"webServiceUrl": "https://api.businesscentral.dynamics.com/v2.0/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/Sandbox254",
"locationName": "Japan East",
"platformVersion": "25.2",
"databaseSize": {
"value": 753664.0,
"unit": "Byte"
},
"ringName": "Production",
"appInsightsKey": ""
},
{
"friendlyName": "2qcj3x-Sandbox253",
"type": "Sandbox",
"name": "Sandbox253",
"countryCode": "JP",
"applicationFamily": "BusinessCentral",
"aadTenantId": "7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62",
"applicationVersion": "25.3.28755.30647",
"status": "Active",
"webClientLoginUrl": "https://businesscentral.dynamics.com/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/Sandbox253",
"webServiceUrl": "https://api.businesscentral.dynamics.com/v2.0/7e47da45-7f7d-448a-bd3d-1f4aa2ec8f62/Sandbox253",
"locationName": "Japan East",
"platformVersion": "25.2",
"databaseSize": {
"value": 770048.0,
"unit": "Byte"
},
"ringName": "Production",
"appInsightsKey": ""
}
]
}
The format of Json can be simply understood as:
- Array is enclosed by square brackets: []
- Object is enclosed by curly brackets: {}
- Values are in the format “key”: “value”
This can be seen when debugging:

All along, if we want to get the value from Json, we always have to read data through a JsonToken. For example,

Source Code: GitHub (Please note that the source code is for reference only, you can improve it according to your own needs)
With this wave (BC26), this has changed significantly. Let’s try the new approach.
procedure GetText(“Key”: Text, [DefaultIfNotFound: Boolean]): Text
Retrieves the value of a property with a given key from a JsonObject as Text.

Very simple.

Next, let’s take a look at JsonArray Data type. I prepared a very simple Json file, I want to read the second value, BMW.

Now we only need the following code to do it, access array values by index: GetText(1)
procedure GetText(Index: Integer): Text
Retrieves the value at the given index in the JsonArray.
Note that this, like the Option Data type, starting with 0.


If the Json Array is contained in a Json Object, the processing is also very simple.


Great. This makes the processing of Json format easier. In the example, I only returned the Text data type. Please choose the correct type during actual development. Give it a try!!!😁
END
Hope this will help.
Thanks for reading.
ZHU
コメント