JSON Management Codeunit

dreez
Member Posts: 73
Hello,
Up to this day I was using Newtonsoft.Json DotNet variables, but the problem is, that in AL it is not allowed to use DotNet variables.
There is a codeunit 5459 JSON Management available which has some external methods that I can use.
I want to store incoming JSON in the table similar to TB1236: JSON Buffer. I had to modify JSON Buffer's ReadFromText function a bit, so I would like to use some functions from JSON Management instead.
Here is the code from JSONBuffer.
I know I can use given JSON Buffer Table, but I would like to know if it's possible to get the same result by using the codeunit.
So my question is: Is it possible? And if yes, then how?
Thank you for your time.
Up to this day I was using Newtonsoft.Json DotNet variables, but the problem is, that in AL it is not allowed to use DotNet variables.
There is a codeunit 5459 JSON Management available which has some external methods that I can use.
I want to store incoming JSON in the table similar to TB1236: JSON Buffer. I had to modify JSON Buffer's ReadFromText function a bit, so I would like to use some functions from JSON Management instead.
Here is the code from JSONBuffer.
ReadFromText(JsonText: Text) JSONTextReader := JSONTextReader.JsonTextReader(StringReader.StringReader(JSONText)); IF JSONTextReader.Read THEN REPEAT INIT; "Entry No." += 1; Depth := JSONTextReader.Depth; TokenType := JSONTextReader.TokenType; "Token type" := TokenType; IF ISNULL(JSONTextReader.Value) THEN Value := '' ELSE SetValueWithoutModifying(FORMAT(JSONTextReader.Value)); IF ISNULL(JSONTextReader.ValueType) THEN "Value Type" := '' ELSE "Value Type" := FORMAT(JSONTextReader.ValueType); Path := JSONTextReader.Path; INSERT; UNTIL NOT JSONTextReader.Read;I am not quite sure if I can modify that code to get the same result with JSON Management Codeunit.
I know I can use given JSON Buffer Table, but I would like to know if it's possible to get the same result by using the codeunit.
So my question is: Is it possible? And if yes, then how?
Thank you for your time.

0
Best Answer
-
I don't know how much of that is implemented in the new types. There will be code that translates directly, and some that won't.
You can request things that you think are missing by submitting a request here: https://github.com/Microsoft/ALAppExtensions, or here: https://aka.ms/BusinessCentralideas5
Answers
-
The AL language has its own variable data types for JSON (and other .net types), and they are based on the same assemblies that are in the JSON Mgt codeunit.
Hit Ctrl+Space in the data type area and see what's available. There are many new ones that are essentially wrappers around common .net objects.
1 -
So, if I am still working with C/SIDE, there is no reason to not use DotNet Newtonsoft.Json objects like JSONTextWriter?
The reason I wanted to use only JSON Management instead was that I wanted to have an easy upgrade to BC15 in the future.0 -
I don't know how much of that is implemented in the new types. There will be code that translates directly, and some that won't.
You can request things that you think are missing by submitting a request here: https://github.com/Microsoft/ALAppExtensions, or here: https://aka.ms/BusinessCentralideas5 -
Thank you for answer.0
-
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions