title: How to serialize Json string in apex
body: <p>I need to parse this json string to values.</p>
  
  <p>"start": { "dateTime": "2013-02-02T15:00:00+05:30" }, "end": { "dateTime": "2013-02-02T16:00:00+05:30" },</p>
  
  <p>The problem is I am using JSONParser in apex (salesforce).
  And my class is: </p>
  
  <pre><code> public class wrapGoogleData{
  
      public string summary{get;set;}
      public string id{get;set;}
      public string status;
      public creator creator;
      public start start;
  
      public wrapGoogleData(string entnm,string ezid,string sta, creator c,start s){
          summary= entnm;
          id= ezid;
          status = sta;
          creator = c;
          start = s;
      }  
  }
  public class creator{
      public string email;
      public string displayName;
      public string self;
  }
  public class start{
      public string datetimew;
  }
  </code></pre>
  
  <p><strong>I am able to get all the datat from this except the datetime in the above string. As datetime is a reserved keyword in apex so i am not able to give the variable name as datetime in my class.</strong></p>
  
  <p>Any suggestion !!</p>
  
  <p>Json Parser code: </p>
  
  <pre><code>JSONParser parser = JSON.createParser(jsonData );
      while (parser.nextToken() != null) {
          // Start at the array of invoices.
          if (parser.getCurrentToken() == JSONToken.START_ARRAY) {
              while (parser.nextToken() != null) {
                  // Advance to the start object marker to
                  //  find next invoice statement object.
                  if (parser.getCurrentToken() == JSONToken.START_OBJECT) {
                      // Read entire invoice object, including its array of line items.
                      wrapGoogleData inv = (wrapGoogleData)parser.readValueAs(wrapGoogleData.class);
  
                      String s = JSON.serialize(inv);
                      system.debug('Serialized invoice: ' + s);
  
                      // Skip the child start array and start object markers.
                      //parser.skipChildren();
                      lstwrap.put(inv.id,inv);
                  }
              }
          }
      }
  </code></pre>