New answers tagged

1 vote
Accepted

How to convert Object fields to JSON in apex?

The fastest way is JSON.serialize(): Account a = [SELECT Name, (SELECT FirstName, LastName FROM Contacts LIMIT 1) FROM Account LIMIT 1]; System.debug(JSON.serialize(a)); The output will be something ...
user avatar
  • 4,068
0 votes

How to convert Object fields to JSON in apex?

Using JSON.serialize(##YourObjectInstance##). This function will return String. For more information see https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Json....
user avatar
5 votes
Accepted

How can I create custom HTTP body

We can make this dynamic by defining class structures, i.e.: public class Data { public String website_id; public List<Column> columns; public String date_from; public String ...
user avatar
3 votes
Accepted

Parsing HTTP JSON Response

When you're traversing throughout your data list, you need to cast each Object to Map<String, Object>. In this Map you can already retrieve id value. Then you should retrieve attributes map, ...
user avatar
6 votes
Accepted

Apex Parse Json response Error Unexpected character ('P' (code 80))

In the documentation, google says that the callback parameter is: callback: Name of the JavaScript function we pass the return to. Now since you are not in a javascript environment (plus you'd need ...
user avatar
5 votes

Apex Parse Json response Error Unexpected character ('P' (code 80))

After doing a little digging, it appears that this API is returning JSONP (JSON with Padding) rather than plain JSON. It looks like it's meant to be used within a <script> tag to sidestep CORS. ...
user avatar
  • 49.6k
3 votes

How to pass ID array from LWC to Apex for VF page parameter

I discovered that the issue was coming from a character limitation on pdfPage.getParameters() (seemed to be limited at 205 characters for me) I got around it by querying using the id of parent object ...
user avatar
  • 436
0 votes

Filtering or Targeting Specific Node in JSON using GTL

Even though there are several GTL filter examples floating around in the official SF docs and around here, I couldn't get them to work. Plus, every time I try to iterate or manipulate a complex JSON ...
user avatar
  • 28.2k
0 votes

System.JSONException: Apex Type unsupported in JSON: Object

Alex had a great answer. Also though something to note is you can use JSON.deserializeUntyped and cast to objects like so: Map<String, Object> payloadMessage = (Map<String,Object>)JSON....
user avatar

Top 50 recent answers are included