Skip to main content
[ This file is autogenerated from apexdoc ]

AqSObjectToJSONConverter

Converts Salesforce records to JSON format based on mapping configuration. Handles hierarchical data structures and field name mapping.

Group modules/mapping tool

Overview​

AqSObjectToJSONConverter is responsible for converting Salesforce SObjects to JSON format. It:

  • Builds hierarchical record trees with parent-child relationships
  • Maps Salesforce field names to external field names
  • Handles lookup field references
  • Converts field values to JSON-compatible formats
  • Supports custom data providers for testing

Usage​

Typically used through AqMappingToolService, but can be instantiated directly:

AqSObjectToJSONConverter converter = new AqSObjectToJSONConverter();
String json = converter.createJSON(accountIds, 'AccountMapping');

Custom Data Providers​

For testing or custom logic, you can provide custom data providers:

AqSObjectToJSONConverter converter = new AqSObjectToJSONConverter(
customObjectDefinitionData,
customFieldDefinitionData
);

See the main module documentation for JSON output structure examples.

Constructors​

public AqSObjectToJSONConverter()​

public AqSObjectToJSONConverter(AqObjectDefinitionMappingData objectDefinitionData, AqFieldDefinitionMappingData fieldDefinitionData)​


Methods​

public List<AqRecordWithChildren> getRecordTrees(List<Id> rootRecordIds, ObjectDefinitionMapping__mdt rootObjectDefinition)​

public String createJSON(List<Id> rootObjectIds, String rootMetadataName)​

public String createJSON(List<Id> rootObjectIds, ObjectDefinitionMapping__mdt rootMetadata)​