Skip to main content
added 435 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

You can create a class to parse the input, roughly outlined as follows:

public class Item {
    public String name, value;
}
@RemoteAction public static void createContact(String jsonObjResult) {
    // Serialize Items
    Item[] values = (List<Item>)JSON.deserialize(jsonObjResult, List<Item>.class);
    // process items to create contacts
}

Note: This would be a lot easier if you used standard JSON notation:

{ "FirstName": "xyz", "LastName": "xyz", "Email": "[email protected]", "Phone": "789456", "BirthDate": "2013-05-13" }

Then, you could serialize the object directly:

@RemoteAction public static void createContact(String jsonObjResult) {
    Contact record = (Contact)JSON.deserialize(jsonObjResult, Contact.class);
    insert record;
}

You can create a class to parse the input, roughly outlined as follows:

public class Item {
    public String name, value;
}
@RemoteAction public static createContact(String jsonObjResult) {
    // Serialize Items
    Item[] values = (List<Item>)JSON.deserialize(jsonObjResult, List<Item>.class);
    // process items to create contacts
}

You can create a class to parse the input, roughly outlined as follows:

public class Item {
    public String name, value;
}
@RemoteAction public static void createContact(String jsonObjResult) {
    // Serialize Items
    Item[] values = (List<Item>)JSON.deserialize(jsonObjResult, List<Item>.class);
    // process items to create contacts
}

Note: This would be a lot easier if you used standard JSON notation:

{ "FirstName": "xyz", "LastName": "xyz", "Email": "[email protected]", "Phone": "789456", "BirthDate": "2013-05-13" }

Then, you could serialize the object directly:

@RemoteAction public static void createContact(String jsonObjResult) {
    Contact record = (Contact)JSON.deserialize(jsonObjResult, Contact.class);
    insert record;
}
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

You can create a class to parse the input, roughly outlined as follows:

public class Item {
    public String name, value;
}
@RemoteAction public static createContact(String jsonObjResult) {
    // Serialize Items
    Item[] values = (List<Item>)JSON.deserialize(jsonObjResult, List<Item>.class);
    // process items to create contacts
}