Skip to main content

JSON

Explore practical guides and implementation patterns for this topic.

Posts

Topic Apex
Apex Development

How to Serialize SOQL Query Results to JSON in Salesforce Apex

Whenever you need to send internal Salesforce data to an external application, a middleware tool like MuleSoft, or a front-end framework, that data must be translated into a universal format. In modern web development, that format is JSON. Converting database records into text strings is a fundamental task for any Salesforce developer. In plain words: When you want to transform your Salesforce database query results into a structured text format that web applications can read, you use the built-in JSON.serialize() method in Apex. This converts complex sObjects into standard JSON strings instantly.
Read article
Apex Development

Demystifying JSON.deserializeUntyped in Apex Salesforce with Code Examples

In plain words: When working with API responses in Salesforce, use JSON.deserialize(jsonString, YourClass.class) if you know the exact structure of the incoming data. This gives you a structured Apex object so you can access data easily (e.g., user.email ). Use JSON.deserializeUntyped(jsonString) if the data structure changes dynamically or you only need a few specific fields. This returns a generic Map or List, requiring you to cast values manually. Almost every Salesforce integration involves a common step: an external system sends you a JSON string, and you need to extract its values using Apex. Salesforce provides two primary methods to accomplish this. In this guide, we will break down both approaches with working examples, highlight common developer pitfalls, and give you a simple rule of thumb for choosing the right one.
Read article
Apex Development

Apex Full Code Examples for HTTPMock in Test Classes

💬 In plain words: JSON.deserializeUntyped parses raw JSON strings into flexible generic Apex maps ( Map<String, Object> ) or lists ( List<Object> )—eliminating the need to define predefined wrapper classes for dynamic third-party API payloads. In Salesforce development, working with JSON information is a common challenge when integrating with external systems or handling data in a flexible and dynamic way. Salesforce provides a powerful method called JSON.deserializeUntyped that allows developers to parse JSON strings into a manageable format. In this blog post, we'll explore the ins and outs of JSON.deserializeUntyped in Apex, understand its usage, and provide practical code examples to demonstrate its capabilities.
Read article
Topic Apex
Apex Development

@HttpPost web service in Salesforce

💬 In plain words: An @HttpPost Apex REST web service allows outside applications to send JSON data directly into Salesforce. The server parses the incoming request payload, processes the data, and sends back a structured JSON response. Building custom web services in Salesforce allows external systems to interact with your org seamlessly. Using the @RestResource annotation alongside @HttpPost , you can easily expose Apex classes as custom REST API endpoints to accept incoming JSON payloads and return dynamic responses.
Read article
Lightning Web Components

How to Easily Download JSON Files in Salesforce LWC (With Code Examples)

When building enterprise features in Salesforce Lightning Web Components (LWC), exporting data as a downloadable file is a frequent requirement. Whether you need to export record payloads, configuration settings, or integration logs, generating and downloading JSON files directly in the browser improves user experience without heavy server overhead. In plain words: You can create and download JSON files client-side in LWC by converting JavaScript objects into a string, wrapping them in a Blob object, and triggering a virtual anchor ( <a> ) tag click.
Read article
Topic Integration & APIs
Salesforce Integration & APIs

How to Process JSON Payloads in Salesforce SOAP Web Services with Apex

In plain words: An Apex SOAP Web Service allows external legacy enterprise systems that communicate via XML/WSDL contracts to send flexible, stringified JSON payloads into Salesforce, where Apex can parse the data and create or update records. While modern integrations typically favor REST architectures, many enterprise systems still require strict SOAP endpoints governed by WSDL files. Passing a JSON string inside a custom Apex SOAP endpoint bridges the gap between legacy XML transport protocols and flexible, modern JSON payloads.
Read article
Topic Integration & APIs
Salesforce Integration & APIs

How to Integrate Google Sheets Batch API with Salesforce Apex: Step-by-Step Guide

Synchronizing high-volume data between Salesforce and Google Workspace is a common architectural requirement. Instead of making individual HTTP callouts for every single row—which quickly burns through Salesforce governor limits—you can leverage Google Sheets batch APIs to read and write large sets of spreadsheet data in a single roundtrip. In plain words: A Google batch integration bundles multiple spreadsheet updates or reads into one HTTP request from Salesforce Apex, drastically saving API limits and cutting transaction times.
Read article