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}]
  • If 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.
    – Derek F
    Oct 24, 2018 at 15:33

1 Answer 1


Json2Apex by adminbooter acts funny when the JSON actually is not simple object but Array.

You have to bit tweak the generated code. As I can see from your code, your JSON is actually an element in an Array.

So you are not parsing an individual instance but an array, This is where adminboster is failing and making class like cls_0 0;

public class ResponseWrapper {
        public String uid;  //72852a55-5be3-496c-904c-fc3fd261f0a4
        public Integer childrenCount;   //0
        public String lastName; //Raudin
        public String checkInDate;  //2016-03-08
        public String checkOutDate; //2016-03-12
        public String status;   //BOOKED
        public Integer adultCount;  //1
        public cls_agency agency;
        public cls_property property;
        public cls_stayDetails stayDetails;
        public String notes;    //
        public String email;    //[email protected]
        public String phoneNumber;  //415-322-2422
        public String cellphoneNumber;  //415-888-6658
        public String firstName;    //Cedric
        public String flightNumber; //XTF1PNS
        public String reasonForTrip;    //Business
        public String preferredCurrency;    //USD
        public Integer petCount;    //1
        public Integer quoteAmount; //200
        public String source;   //ORBIRENTAL_FORM
        public String city; //Irvine
        public String state;    //California
        public String secondaryEmail;   //[email protected]

        class cls_agency {
        public String uid;  //4f6a3a32-6d57-450d-8b46-12547854
        public String name; //Responseev
    class cls_property {
        public String uid;  //4f6a3a32-6d57-450d-8b46-44abb3b01994
        public boolean isActive;
        public String 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.
        public Integer baseGuests;  //4
        public Integer cleaningFeeAmount;   //160
        public Integer baseDailyRate;   //220
        public boolean acceptInstantBook;
        public String bathrooms;    //2
        public Integer maximumGuests;   //6
        public String state;    //California
        public String countryCode;  //US
        public Integer securityDepositAmount;   //500
        public String address1; //159 Campolindo Road
        public String webLink;  //http://point-reyes-vacation-rental.com/
        public String address2; //
        public String externalID;   //
        public Integer bedrooms;    //2
        public String type; //HOUSE
        public String city; //Point Reyes Station
        public String picture;  //https://www.orbirental.com/img/uploader/livingroom4_1.jpg
        public String postalCode;   //94956
        public String name; //The Quail's Nest Cottage
        public Integer minimumStay; //1
        public String availabilityCalendarUrl;  //https://www.orbirental.com/calendar/232.ics
        public cls_photos[] photos;
        public Integer floor;   //2
        public Integer areaSize;    //30
        public String areaSizeUnit; //SQUARE_METERS
        public Integer extraGuestFee;   //50
        public Double taxationRate; //12.5
        public Double longitude;    //48.1914945
        public Double latitude; //19.1914945
        public String currency; //USD
    class cls_photos {
        public String url;  //https://www.orbirental.com/img/uploader/view_0.jpg
        public String description;  //my house
    class cls_stayDetails {
        public String departureDate;    //2017-02-25 11:00:00.0
        public String arrivalDate;  //2017-02-24 15:00:00.0
        public String extraNotes;   //Some notes
    public static ResponseWrapper[] parse(String json){
        return (ResponseWrapper[]) System.JSON.deserialize(json, ResponseWrapper[].class);

To get arrival date :

List<ResponseWrapper> respWrapperList = ResponseWrapper.parse(json);
if(respWrapperList!=null && !respWrapperList.isEmpty()){
  • So how do I get the arrivalDate value from cls_stayDetails?
    – Thomas
    Oct 25, 2018 at 6:06
  • @Thomas added code to get arrival date. Oct 25, 2018 at 8:59
  • Thanks I tried the above but get: System.JSONException: For input string: "4083.5" at [line:1, column:7046]
    – Thomas
    Oct 25, 2018 at 9:49
  • Is there a value 4083.5 in your JSON? I cant find it in the JSON u posted in this question Oct 25, 2018 at 9:50
  • I added the JSON string where "quoteAmount":4083.5 is in the JSON String
    – Thomas
    Oct 25, 2018 at 10:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .