function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kam.ax1015Kam.ax1015 

Passing nested structure to Apex Rest controller

Hello,

 

Following the thread 

http://boards.developerforce.com/t5/REST-API-Integration/REST-API-Inserting-complex-transaction/m-p/286639

  @HttpPost
    global static string create(Account account, List<Contact> contacts) {
        insert account;
        for (Contact c : contacts)
            c.accountId = account.Id;
        insert contacts;
        return account.id;
    }

Let's say if each contact itself has nested objects, or other example is Account can have multiple orders and each order can have order details and each order detail can have multiple parts. Is it possible to pass that? Would Apex controller unmarshall the nested structures? I wish there were REST serializers/deserializers as part of Salesforce APEX framework to do that. Please advise.

 

Thanks,

Kam

 

 



SuperfellSuperfell

You can define custom classes that have the structure you want, similar to how it works for the apex soap services.

Kam.ax1015Kam.ax1015

But we still need to deserialize the REST string in to that complex structure? In java I use flejson library to do that. Right?

 

Thanks,

Kam

SuperfellSuperfell

Ahh, I misspoke, that's not in the current pilot version, but its on the plan.

Kam.ax1015Kam.ax1015

So I guess answer is right now there is no easy way to do that.

 

Thanks a lot for your prompt help.

 

Kam