Sep 29, 2024
88 Views
Comments Off on Automation of JSON2APEX – My journey to writing my own automated tooling for this!
0 0

Automation of JSON2APEX – My journey to writing my own automated tooling for this!

Written by

Lyrics

Each and every time developing an integration, I wanted to automate the most tedious and routine part of it – creating wrappers for integration entities. I found a couple of tools for it, but all of them are online tools. That meant I had to leave the comfort and speed of automation via command-line and my keyboard, which I did not prefer to do. I used Sublime for a while and tried to find some polygons that would help me, but failed. But, that’s alright – as they say, if you can’t find something that suits your requirements – DIY!

Basic JSON2Apex

Basically, this tool can create an Apex class from a JSON sample, e.g. an API response. How is this any different from online tools, you may ask? Most online tools do not care about having the same attributes in entities and often generate a lot of almost similar classes. Well, when I’m generating a code I want to get rid of manual completely, so I don’t want to look through generated classes to find duplicates. JSON2Apex handles similar properties and generates only one wrapper class for them.

Meta-language

There’s one more feature in the plugin – it allows you to code in a meta-language. This means you can quickly create some kind of an interface for the future class. You describe the whole class in YAML, specifying interfaces it implements and classes it extends, and JSON2Apex generates a class with methods’ notations. So you should only insert implementation.

Creating API

At the time when I started coding this tool, I was working on an API for an Angular app, and we had to document it in Swagger 2.0. Researching the Swagger syntax, I thought that it would be nice to have a tool that would create an API from the description. Unfortunately, I’ve found nothing useful for generating Apex from Swagger, so, once again, I started coding it myself. The work is still in progress, but soon we will generate a Salesforce custom REST resource out of an API description written in Swagger. RAML 1.0 is also in the works!

Try it yourself! – https://packagecontrol.io/packages/JSON2Apex

Article Categories:
Salesforce
Ramya Singh
https://thestarbiznews.com

Ramya Singh isn't your average tech blogger. Sure, she's got the brains to understand the latest algorithms and the jargon to explain them in plain English. But she's also got a twinkle in her eye and a way of weaving technology into the fabric of everyday life that makes it nothing short of fascinating. Whether she's reviewing the latest smartphone, exploring the potential of virtual reality, or delving into the ethical implications of artificial intelligence, Ramya does it with a contagious enthusiasm that makes you want to learn more, do more, and be a part of the exciting world of tech. So, if you're looking for a tech blog that's informative, inspiring, and just plain fun, follow Ramya Singh. She'll take you on a journey through the ever-evolving landscape of technology, and you might just find yourself a little bit more tech-savvy (and a lot more excited) along the way.