0
 public static WS_BankStatementResponse parse(String json){
    String jsonReplacedString = json.replace('"date":', '"startDate":');
    System.debug('String Replaced : '+jsonReplacedString);
    return (WS_BankStatementResponse) System.JSON.deserialize(jsonReplacedString, WS_BankStatementResponse.class);
    System.debug('Deserialized : '+); // I want to print in debug
}
2

You are trying to print the debug after return statement which will be an unreachable statement.

Please write it above the return statement and check.

OR

You can write your debug statement before return as something like this System.debug('response after deserialize--'+(WS_BankStatementResponse) System.JSON.deserialize(jsonReplacedString, WS_BankStatementResponse.class));

so that you can know what's it returning without getting unreachable statement error.

  • I want to check value after deserialized – Tarsbir Singh Mar 18 at 6:56
  • I have edited the answer. please check – 7'7' Mar 18 at 7:10
0

You are returning the response before writing the print statement. This is a compile time error you can see. Do it as:

public static WS_BankStatementResponse parse(String json){
    String jsonReplacedString = json.replace('"date":', '"startDate":');
    System.debug('String Replaced : '+jsonReplacedString);
    WS_BankStatementResponse response = (WS_BankStatementResponse) System.JSON.deserialize(jsonReplacedString, WS_BankStatementResponse.class);
    System.debug('Deserialized : '+ response); // I want to print in debug
    return response;
}
  • Variable does not exist: response – Tarsbir Singh Mar 18 at 6:55
  • response is defined in the line after 1st System.debug statement! – Aditya Vijay Mar 18 at 7:12

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.