Skip to content

andrii-solokh/JSONObjectPlainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Deploy to Salesforce

JSONObjectPlainer

Transform SObject object with parent relationships to plain JSON object. Was developed to simplify data binding for lighting-datatable. lighting-datatable doesn't support column field name with relation object like:

{
  
  Id: "0QL5000000380hoGAA",
  Product2: {
    Description: "Description"
    Id: "01t50000003A1QvAAK"
    Name: "MSB7890-ES2F"
  },
  Product2Id: "01t50000003A1QvAAK",
  Quantity: 1
}

JSONObjectPlainer transform it to:

{
  Id: "0QL5000000380hoGAA",
  Product2.Description: "Description",
  Product2.Id: "01t50000003A1QvAAK",
  Product2.Name: "MSB7890-ES2F",
  Product2Id: "01t50000003A1QvAAK",
  Quantity: 1
}

How to use

JSONObjectPlainer.plain() accepts List of SObjects or single record as well.

@AuraEnabled(cacheable=true)
public static List<Object> getItems(Id quoteId){
    List<QuoteLineItem> items = [
        SELECT Product2.Name, Product2.Description, Quantity
        FROM QuoteLineItem
        WHERE QuoteId = :quoteId
    ];
    return JSONObjectPlainer.plain(items);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages