community postAL Developmentcommunity - not Microsoftreviewed - checked by Opus

How to Work with JSON in Business Central’s AL Code

Working with JSON in Business Central AL involves understanding JSON structures (values, objects, arrays) and using JsonObject, JsonArray, and JsonToken types to parse incoming JSON data and export records as JSON. This is essential for API integrations, AI systems, and computer-to-computer data exchanges.

post Aardvark Labs

Marcel Chabot · 2025-06-06 · 1,754 words · about 8 min

"REST APIs use JSON and are generally simpler, human readable, and leaner."

Key points

  • JSON is built from values (name and value pairs), objects (containers of values and arrays) and arrays (lists of objects or values)
  • Parse incoming text with JsonObject.ReadFrom and read fields with GetText, GetInteger and GetArray
  • Iterate arrays with foreach over JsonToken, converting each token to a JsonObject
  • Export records by building JsonObject and JsonArray structures, then WriteTo text and download via a Temp Blob stream
  • The author notes REST APIs with JSON are simpler and leaner than SOAP APIs with XML

Quotes

  • “REST APIs use JSON and are generally simpler, human readable, and leaner.” (Explains why JSON is the standard for modern API communication in Business Central)
  • “Working with JSON data is critically important as we progress into more complex AI and data integration systems.” (Highlights the strategic importance of JSON skills for developers building AI and integration solutions)

AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

  • other “JsonObject”
  • other “JsonArray”
  • other “JsonToken”
  • other “Temp Blob”
  • other “TextBuilder”

Context

  • Features: JSON parsing, JSON export, File upload and download, REST API integration, Record serialization, Array iteration

Source: Aardvark Labs, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.