Creating complex JSON structure in AL and Business Central

  Рет қаралды 5,311

Erik Hougaard

Erik Hougaard

Күн бұрын

Find more information at my blog www.hougaard.com or follow me on / ehougaard
Source code can be found here: github.com/hou...

Пікірлер: 20
@sufletdemustang
@sufletdemustang Жыл бұрын
Very helpful, Sir! I watched all json videos, and more videos regarding other topics. Your content is making a big difference. Thank you!
@jonaslundstrom7461
@jonaslundstrom7461 2 жыл бұрын
Great as always, Erik! A question. Is it all of them really called "Keys" and not "JSON Tokens"? I know for instance when you make an API to Sales Invoice, for example, BC will return a token called "Key" with a JSON Value. Much oblige
@Hougaard
@Hougaard 2 жыл бұрын
A token is either a jsonobject, a jsonarray or a jsonvalue. A key is the indexing inside an jsonobject.
@brianjuhl9451
@brianjuhl9451 2 жыл бұрын
Keep up the good work Erik Little workaroud for pretty json local procedure PrettyJson(var JsonText: Text) var JSONManagement: Codeunit "JSON Management"; begin if JSONManagement.InitializeFromString(JsonText) then begin JsonText := JSONManagement.WriteObjectToString(); end; end;
@stefanushendra5986
@stefanushendra5986 2 жыл бұрын
Nice one Erik, just wonder have you ever met json with special characters. Like when exporting Item Card in Description you have special charcaters like " or tab or ' or * I've read we can use like \" or so but that means have to search all char in the description.
@youneselhamss2908
@youneselhamss2908 Жыл бұрын
Kan du lave en video om hvordan man laver en page i bc hvor man kan sende en ticket til zendesk. Jeg har hul igennem Zendesk api'et via postman, og jeg har en side klar lavet i AL, men jeg kan ikke lige gennemskue hvordan jeg poster til api'et i AL
@Hougaard
@Hougaard Жыл бұрын
Der er allerede mange videoer om web service kald.. prøv at blive inspireret af nogle af dem?
@realeques
@realeques 2 жыл бұрын
How do you store an array of values for one fiield ? e.g. "Field1" : "["Value1","Value2","Value3"]
@Hougaard
@Hougaard 2 жыл бұрын
yourjsonobject.Add('FIeld1",);
@realeques
@realeques 2 жыл бұрын
​@@Hougaard thanks for replying, but i don't have a JsonArray, i only have an like: "BrandNames": [ "Gucci","Prada","Fendi"] and i dont know how to store this in a JsonToken . My only workaround right now is passing it as a string and when i get the and reading the responsearray as a string and splitting it into a List ( which could create inconsistencies )
@Hougaard
@Hougaard 2 жыл бұрын
So that json as Text, so you gotta parse it first (with .ReadAs())
@sakis8431
@sakis8431 2 жыл бұрын
Thanks for the valuable content Erik! Perhaps you could get into making such complex structures available thru an API? We as BC Developers are constantly confronted with interfaces from and to external systems. But, MS has only the API Page for us to publish a REST/JSON API. The problem there is, you can only go 2 levels deep with a subpage. Yes there’s a OdataEDMType but 1. you cannot place an array (edm collection type) into another OdataEDMType and 2. it is deprecated since version 6, leaving us with an API Page and Subpage, max 2 levels deep. Since 3 versions no replacement for it! This is a joke. I wish they would allow a JSONObject Parameter in a codeunit, that way you could publish that codeunit as a web service and the parameter passes the json object, respectively XMLDocument. What’s your point of view? Perhaps i am missing something? Thanks Erik!
@Hougaard
@Hougaard 2 жыл бұрын
What we're missing is a modern replacement for xmlport as a parameter.
@sakis8431
@sakis8431 2 жыл бұрын
@@Hougaard Yes there’s already an object type XMLDocument (.net equivalent) that fits as replacement for XMLPort. But unfortunately you cannot publish it as a web service. We don’t even need SOAP anymore, it’s dead anyway. All we need is being able to publish a web service with either a XMLDocument or JSONObject parameter or perhaps give us access to the request object overall. Let us do the handling in code. BC Developers aren’t NAV Bookkeepers anymore :D. Perhaps there’s a reason why it is not possible but I cannot think of a reasonable explanation. It’s possible in almost every other language. Where’s the right place to suggest ideas?
@Hougaard
@Hougaard 2 жыл бұрын
I'm typically just doing function(input : Text) : Text and then do json parsing on input and json formatting on the return value. The only "issue" with this approach is that content-type is not set to application/json - but I just ignore that.
@sakis8431
@sakis8431 2 жыл бұрын
@@Hougaard yes i thought of that too but unfortunately there’s another issue: due to the text parameter the input json itself has to be encapsulated in a string, like „{ „key“: „value“}“ instead { „key“: „value“}. This is not valid according to REST / JSON specification. I have to explain that to the counterpart developer, complicating things for both sides…
@drimmelzwaan
@drimmelzwaan 2 жыл бұрын
VSCode does know how to format json. Paste it into a .json file and do ‘format document’. No need for external dev toys
@Hougaard
@Hougaard 2 жыл бұрын
But I like DevToys :)
2 жыл бұрын
Great Erik A question. Could you please make a tutorial about differences between adding header to an http client with DefaultRequestHeaders and with HttpContent.GetHeaders(HttpHeaders) and HttpHeaders.Add. Thank you ever so much
@Hougaard
@Hougaard 2 жыл бұрын
I'll put that on the list :)
Hidden Gems in Visual Studio Code AL Language and Business Central
11:17
How I Turned a Lolipop Into A New One 🤯🍭
00:19
Wian
Рет қаралды 11 МЛН
Хасанның өзі эфирге шықты! “Қылмыстық топқа қатысым жоқ” дейді. Талғарда не болды? Халық сене ме?
09:25
Демократиялы Қазақстан / Демократический Казахстан
Рет қаралды 332 М.
MY HEIGHT vs MrBEAST CREW 🙈📏
00:22
Celine Dept
Рет қаралды 46 МЛН
Watermark your data with hash values in AL and Business Central
29:56
Erik Hougaard
Рет қаралды 1,9 М.
Let's create a Record2Json Function in AL and Business Central
34:50
Erik Hougaard
Рет қаралды 2,7 М.
Getting started with AL Go! for Github and Business Central
19:23
Erik Hougaard
Рет қаралды 5 М.
Handle any CSV file with the CSV Buffer in AL and Business Central
35:38
UI Hacks with Javascript in Business Central
24:01
Erik Hougaard
Рет қаралды 7 М.
How I Turned a Lolipop Into A New One 🤯🍭
00:19
Wian
Рет қаралды 11 МЛН