Display Strings as JSON

If you are into APIs and Endpoints you will at some point store requests or responses or both in salesforce. The easiest way to do this is to create a long text area field that will hold the values for you. That might be custom process or even a installed like the App for the Stripe integration.

There you will have a field called stripeGC__Request_Body__c and the values look like this:

Now this is not super easy to read so I figured there has to be a way to display this as a JSON in Salesforce itself.

And here we go:

This makes some uses just easier to handle. I created a LWC you can find here: https://salesforcepanda.com/jsonviewer-lwc/

There is an option with and without involving apex. For this use case it’s without apex as the LWC is placed on the record / object that holds the field itself.

Just make sure to switch the object and field according to your needs!

import REQUEST_FIELDS from ‘@salesforce/schema/yourObject.yourField’;

Leave a Reply

Your email address will not be published. Required fields are marked *