The requirement was to get the JSON Structure of an Account object for a third-party tool to Map the fields and Load the object fields.
The Structure needed was only to have the Object name and all the Field Names from the object like Below:
I simplified the way to extract the actual JSON Structure for an Object and get all the fields. Below I have given the code for getting the JSON structure for both API names of the fields and Label names.
Execute below in Execute Anonymous Window for JSON structure with API names of the fields
After executing, Open Raw Log and Capture the Unformatted structure of the object and use the Online JSON formatter to get the formatted version like below.
This will help us to save time in extracting the JSON Structure of SObject.
Login into the Sandbox that you would like to query on objects
After logging in, To the left hand side we can see all the objects. Need to double click on the object we want and we can see all the fields present in the object.
As per our requirement, we should enhance the query and add the conditions to get the results on the fields by clicking on query at the bottom.
Hope this tool helps in improving the querying time and checking the values on the fields.
In the call outs or Integrations that we do from Salesforce to External Systems, we should pass the Endpoint URL and Password in the Header to hit the External System.
Using the Named Credentials we can Put these Endpoint URL and Password in a Label and can expose that label in the code.
Below are the Steps for Navigating to Named credentials:
Setup -> Type Named Credentials -> Setup the Named Credentials with all the details
This is considered as one of the best practices (Not exposing the URL and Password in the code)