I have created a component which takes users input and when the submit button is hit I want the component to insert my transaction__c records from the created JSONList,

As it stands my example json looks like so for 2 transaction records:


This list is past into the apex controller "insertTransactions" method which I currently have like so:

    public static void insertTransactions(String tListJSON) {
        //insert tListJSON;
        catch(exception e){
            System.debug('error inserting transactions @ ' + e);

I have tried creating a json2apex class but the __c isn't accepted so what are my options here for getting this to insert correctly?



You need to use the JSON class in Apex to deserialize it:

JSON.deserialize(tListJSON, List<Transaction__c>.class);
  • Another option is to use a wrapper class as you would be 100% sure on what to expect with serialize/de-serialize
    – Raul
    Nov 6 '17 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.