You need to sign in to do that
Don't have an account?
Artem Artemenko 9
How i can get data by key after i do Body.toString()
Hi, I`m junior in apex, I took data from static resource, then i want to get data by key from this String, but i dont know how.
//Get static resource StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'GetCityResource' LIMIT 1]; String body = sr.Body.toString(); //here i want to take name value
{"coord":{"lon":27.57,"lat":53.9},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"base":"stations","main":{"temp":20,"feels_like":19.51,"temp_min":20,"temp_max":20,"pressure":1013,"humidity":82},"visibility":10000,"wind":{"speed":4,"deg":50},"clouds":{"all":75},"dt":1592830206,"sys":{"type":1,"id":8939,"country":"USA","sunrise":1592789886,"sunset":1592851521},"timezone":10800,"id":625144,"name":"Atlanta","cod":200}
You could loop through the keyset and grab whatever matches your criteria.
Or try something like this:
Let me know if this helps
Anudeep
All Answers
You could loop through the keyset and grab whatever matches your criteria.
Or try something like this:
Let me know if this helps
Anudeep
Thank you, second variant pretty good, also read in this topic (https://developer.salesforce.com/forums/?id=9060G000000BhCbQAK) and complete this. My solution below.