Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

2

The format you are getting is not a standard datetime format according to salesforce documentation and w3.org documentation. If you get the properly formatted datetime then using below will give you correct date: String currDT = '2016-04-10 00:00:00'; Date myDate = Date.valueOf(currDT); However, if you are not able to get properly formatted date and ...


0

While the question itself isn't very good (no research or attempt to solve before asking), I think the idea behind it is worth exploring. At a high (and thoroughly unsatisfying) level, you don't need to do anything special here. Using JSON.deserializeUntyped() to get a Map<String, Object> would work, but it wouldn't be easy to use the deserialized ...


0

I just found out the request has to be multipart file upload request consisting of filename, MIME type, and the file stream. below is the type of request I want to create in apex: POST /api/rest/v6/transientDocuments HTTP/1.1 Host: api.na1.echosign.com Authorization: Bearer MvyABjNotARealTokenHkYyi Content-Type: multipart/form-data Content-Disposition: ...


0

Check the solution called "json2apex". It creates for you all the classes structures and then you can adapt to your code.


0

I had a similar issue, and discovered it was a problem with my client. I was producing JSON directly to a String, and giving the String to Jackson to produce JSON. Jackson encodes it, with the result that you get invalid JSON: the quotes around the field names get escaped: \"myField\" : 123 instead of "myField" : 123


0

Instead of doing the operation inside a for loop, you can break the operation into multiple steps.I just framed a sample to break your logic into multiple part. Chck this - map < Integer, AFTR0__c > allAFTR0Map = new map < Integer, AFTR0__c > (); Integer index = 0; for (AFTR0__c curAFTR : data.AFTR0) { AFTR0__c astr = new AFTR0__c(); ...


0

Your code is good. I don't see any problem with that. You succeeded to parse the JSON response and to put it into a map. What you see in the System.debug is the display of the Map (it will not display all the map). You can verify with another way: Map<String, Object> results =(Map<String, Object>)JSON.deserializeUntyped(response.getBody()); ...


1

Not entirely sure that this would work, but you could try the SSJS RaiseError function, here's an example: <script runat="server"> var StatusAndRequestID = [0,0]; var newObject = Platform.Function.InvokeCreate(CreateRequest,StatusAndRequestID,Options); var status = StatusAndRequestID[0]; var requestID = StatusAndRequestID[1]; if(Result != ...


4

Try it with JSON like: {"stock_prices":[{"code":"AAPL.US","timestamp":1569593940,"gmtoffset":0,"open":220.54,"high":220.96, "low":219.79,"close":220.24,"volume":3397713,"previousClose":219.89, "change":0.35,"change_p":0.159}]} Your code expects an object with a property "stock_prices" that is an array of objects. If that isn't what you want, and you need ...


3

The default access modifier in Apex is private. For your inner classes to be visible to code outside their parent class, you need to explicitly declare them public, e.g., public class cls_main { public Double temp; //280.32 public Integer pressure; //1012 public Integer humidity; //81 public Double temp_min; //279.15 public ...


1

Your in the right way! Here, after getting instance as a Map, just retrieve the needed value: Map<String, Object> deserialized = (Map<String, Object>) JSON.deserializeUntyped(resGetNrw.getBody()); for (Object instance : (List<Object>) deserialized.get('results')) { Map<String, Object> data_i = (Map<String, Object>) ...


4

That is because HTML will load before your external call finishes and Profile will be undefined before getting response and so I would suggest to use conditional rendering in HTML itself so that you can fetch the values directly instead of increasing Javascript code for implementing multiple getters. HTML: <template> <template if:true={profile}...


2

Change your template to use a getter that checks for null down the object tree in JS get name(){ let returnValue = ''; if(this.profile && this.profile.Name && this.profile.Name.First){ returnValue = this.profile.Name.First; } return returnValue; } in html <template> {name} </template> What's happening is you are ...


0

Interesting.. Unfortunately you can't use limit and offset with JSON deserialize. But you can do the same programmatically, iterate deserialize object and filter records by 10. If my understanding is right, you are getting a JSON which may contain multiple records but you need to add pagination there? you can use traditional for loop in apex so that you ...


Top 50 recent answers are included