As interacting with WebServices, especially JSON/REST based WebServices, becomes more and more important, it was very good to see that the new NAV dev environment made it quite easy to do exactly that a couple of releases ago. After reading AJ Kauffmann’s excellent blog post on that topic, I had the idea to auto-generate that code based on a JSON file, so that you no longer need to write a single line of code to get a working base structure. With release 2.3.0 of my VS Code extension this is now possible!
For the following steps I assume that you already have an AL project in place. The hello world one, that you can get with command “AL: Go!” works fine as well. The workflow after installing my extension is as follows:
The whole process should look like this:
If you run into problems or have ideas how to improve the extension, please let me know on Github. If you like the extension, rate it or even write a review.
Thanks a lot to AJ Kauffmann for allowing me to build on his code!
A small addition comes with release 2.4.0: You can now select some lines of JSON in VS Code and start generation with that selection. This allows you to handle nested objects as you can just select the nested part (but you will have to implement the parent / child connection yourself). And it also can serve as a workaround for the missing auth feature as you can download the JSON e.g. in a browser where you can enter username and password, then paste it in VS Code and start generation (but you will again have to implement authentication in AL yourself).
Hi Tobias, awesome blog. I was wondering if you know if it is possible to dive into a hierarchical json file (mine has about 4 levels deep), and extract all objects dynamicly (as in your post).