I searched all over but not found the right one.

My Body string below,


My Class here

global static void processPermSetDelegation() {  

    List<permissionDataWrapper>  delegationMap = (List<permissionDataWrapper>)JSON.deserialize(RestContext.request.requestBody.toString(),permissionDataWrapper.class); 
    for(permissionDataWrapper cp : delegationMap) {
        for(string s: cp.assignPermSetNames )
            System.debug('Assign :------'+s);
        for(string a: cp.revokePermSetNames)
            System.debug('Revoke :------'+a);


global class permissionDataWrapper {
    public String EmployeeNumber {get;set;}
    public Set<String> assignPermSetNames {get;set;}
    public Set<String> revokePermSetNames {get;set;}
    permissionDataWrapper () {
        assignPermSetNames = new Set<string>();
        revokePermSetNames = new Set<string>();

Error :

Malformed JSON: Expected '{' at the beginning of object

  • 1
    This line is causing the issue: {"revokePermSetNames":"RemovPerm3","RemovPerm4"], – itzmukeshy7 Jun 14 '17 at 11:25
  • In this line, you forgot to add the starting square bracket [ to start array. – itzmukeshy7 Jun 14 '17 at 11:26
  • Yeah that's the only error I encountered as well, though with a different message. – Adrian Larson Jun 14 '17 at 11:27
  • How are you passing the body? – itzmukeshy7 Jun 14 '17 at 11:27
  • I have pasted wrong body. I will edit now. – bharath Jun 14 '17 at 11:28

Try this ;)

List<permissionDataWrapper>  delegationMap = (List<permissionDataWrapper>)JSON.deserialize(RestContext.request.requestBody.toString(), List<permissionDataWrapper>.class);

You need to pass the List<permissionDataWrapper>.class not permissionDataWrapper.class for the 2nd parameter(JSON.deserialize(1st, 2nd)) because you are processing a list not a single item.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.