• pramod8585
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

my question is that when a record is inserted through webservice callout.we need to create a new salesforce username to that record account.so, i am unable to write the apex code for tha

my question is that when a record is inserted through webservice callout.we need to create a new salesforce username to that record account.so, i am unable to write the apex code for tha

In Apex REST, regarding returning values, what's the difference between

     [return leadList;]

and

     [return JSON.serialize(leadList);]?

 

I'm seeing they serialize differently.

The former returns:

     [{City"Fargo", FirstName"Test", LastName"McTesty", State"ND"}]

The latter returns:

     [{"attributes":{"type":"Lead"},"State":"ND","FirstName":"Test","LastName":"McTesty","City":"Fargo"}]

 

The docs say: "An Apex method with a non-void return type will have the return value serialized into RestResponse.responseBody.", but what does this mean? What method of serialization is used?

 

So, it seems that if we use the JSON serializer, we'll get some extra information beyond just the fields I want to send. Why does the JSON serializer add the extra 'attributes' property? It seems this extra complexity means that we shouldn't use the JSON serializer for REST responses, sound right? My Javascript framework seems to be choking on the latter.

 

Or a better question: What serialization technique is used by the former, and why is it different from the latter?

 

*edit*

After testing a bit more with custom objects, not sObjects, it seems that the former method will resolve easily to JS Object by a JS client, while the latter method will resolve to a JSON string. 

  • April 05, 2012
  • Like
  • 0