I am newbie trying to find a wordflow which makes it easy to convert JSON strings to apex I used adminbooster but get for example
public cls_0 0;
public class cls_0 {
public cls_0 0;
throws an error in the dev console
How do I make use of this use this in my callout and I am not shure but is [{},{}] a list in Json an {} an object. I managed to get thies working for a {} json string but below is giving me some trouble
[
{
"uid": "72852a55-5be3-496c-904c-fc3fd261f0a4",
"childrenCount": 0,
"lastName": "Raudin",
"checkInDate": "2016-03-08",
"checkOutDate": "2016-03-12",
"status": "BOOKED",
"adultCount": 1,
"agency": {
"uid": "4f6a3a32-6d57-450d-8b46-12547854",
"name": "Responseev"
},
"property": {
"uid": "4f6a3a32-6d57-450d-8b46-44abb3b01994",
"isActive": true,
"description": "This Point Reyes House is located on a quiet rural lane, 2 mns from the village of Point Reyes Station, just one hour north of downtown San Francisco.",
"baseGuests": 4,
"cleaningFeeAmount": 160,
"baseDailyRate": 220,
"acceptInstantBook": false,
"bathrooms": "2",
"maximumGuests": 6,
"state": "California",
"countryCode": "US",
"securityDepositAmount": 500,
"address1": "159 Campolindo Road",
"webLink": "http://point-reyes-vacation-rental.com/",
"address2": "",
"externalID": "",
"bedrooms": 2,
"type": "HOUSE",
"city": "Point Reyes Station",
"picture": "https://www.orbirental.com/img/uploader/livingroom4_1.jpg",
"postalCode": "94956",
"name": "The Quail's Nest Cottage",
"minimumStay": 1,
"availabilityCalendarUrl" : "https://www.orbirental.com/calendar/232.ics",
"photos": [
{
"url": "https://www.orbirental.com/img/uploader/view_0.jpg",
"description" : "my house"
}
],
"floor": 2,
"areaSize": 30,
"areaSizeUnit": "SQUARE_METERS",
"extraGuestFee": 50,
"taxationRate": 12.5,
"longitude" : 48.1914945,
"latitude" : 19.1914945,
"currency": "USD"
},
"stayDetails": {
"departureDate": "2017-02-25 11:00:00.0",
"arrivalDate": "2017-02-24 15:00:00.0",
"extraNotes": "Some notes"
},
"notes": "",
"email": "[email protected]",
"phoneNumber": "415-322-2422",
"cellphoneNumber": "415-888-6658",
"firstName": "Cedric",
"flightNumber": "XTF1PNS",
"reasonForTrip": "Business",
"preferredCurrency": "USD",
"petCount": 1,
"quoteAmount": 200,
"source": "ORBIRENTAL_FORM",
"city": "Irvine",
"state": "California",
"secondaryEmail": "[email protected]"
}
]
Aminbooster returns
public static fromJSON parse(String json){
return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
}
Parsing returns empty []
List<fromJSON> MyClass = fromJSON.parse(response.getBody());
In this example how would I achieve the value arrivalDate from staydetails
Update Json:
[{"lastName":"Tester","notes":"","secondaryEmail":"","adultCount":0,"city":"tester","postalCode":"000000","source":"FORM","checkInDate":"2018-10-19","uid":"0000-0000-0000-0000-eeb619ba3be1","checkOutDate":"2018-10-31","countryCode":"US","quoteAmount":4083.5 ,"property":{"city":"Test","latitude":0,"type":"HOUSE","bathrooms":0,"photos":[],"picture":"http://staging.orbirental.com/img/littlehouse.png","bedrooms":0,"uid":"0000-0000-0000-0000-0000","maximumGuests":6,"acceptInstantBook":false,"cleaningFeeAmount":0,"areaSizeUnit":"SQUARE_FEET","name":"Test","securityDepositAmount":0,"currency":"USD","state":"Test","baseGuests":4,"floor":0,"availabilityCalendarUrl":"http://staging.orbirental.com/calendar/10042.ics","areaSize":0,"baseDailyRate":220,"minimumStay":2,"longitude":0},"stayDetails":{"extraNotes":"","departureDate":"2018-10-31 14:11:00.0","arrivalDate":"2018-10-19 14:11:00.0"},"modified":"2018-10-19 12:12:46.0","state":"Test","email":"[email protected]","childrenCount":0,"petCount":0,"reasonForTrip":"","agency":{"uid":"0000-0000-0000-0000-0000","name":"Test"},"address2":"","address1":"tester","created":"2018-10-19 12:12:46.0","flightNumber":"","firstName":"Test","phoneNumber":"","status":"BOOKED","infantCount":0}]
public cls_0 0;
isn't immediately throwing up a red flag for you, it should be. Variable names in Apex must start with an ascii letter.