You need to sign in to do that
Don't have an account?
Getting "System.JSONException: Illegal value for boolean" error when running my test method
I'm trying to write a test method for the following Apex class:
Here is the test method as written so far:
The full error message is System.JSONException: Illegal value for boolean: False at [line:1, column:421]
Class.System.JSON.deserialize: line 15, column 1
Class.HealthProj.parse: line 32, column 1
Class.HealthProj_Test.testParse: line 27, column 1
I've tried using
// JSON File structure for HealthProjectPocHttpCalloutFlow class. public class HealthProj { public ContactInformation contactInformation; public String access_token; public Integer expires_in; public String token_type; public DateTime lastSynced; public class ContactInformation { public String FirstName; public String LastName; public String Email; public String X1819_User_ID; public Date Birthdate; public String phone; public String MailingStreet; public String MailingCity; public String MailingCountry; public String MailingState; public String MailingPostalCode; public String gender; public String version; public Boolean Active; } public static HealthProj parse(String json) { return (HealthProj) System.JSON.deserialize(json, HealthProj.class); } }
Here is the test method as written so far:
// // Generated by JSON2Apex http://json2apex.herokuapp.com/ // @IsTest public class HealthProj_Test { static testMethod void testParse() { String json = '{'+ ' \"contactInformation\": {'+ ' \"FirstName\": \"Joe\", '+ ' \"LastName\": \"Tester\", '+ ' \"Email\": \"bbb@ds.com\", '+ ' \"X1819_User_ID\": \"4324324234324242342\",'+ ' \"Birthdate\": \"2018-07-05\",'+ ' \"phone\": \"382123\",'+ ' \"MailingStreet\": \"num\",'+ ' \"MailingCity\": \"NYC\",'+ ' \"MailingCountry\": \"USA\",'+ ' \"MailingState\": \"NY\",'+ ' \"MailingPostalCode\": \"12345\",'+ ' \"Gender\": \"M\",'+ ' \"Active\": \"False\",'+ ' \"Version\": \"1\"'+ ' }'+ '}'; HealthProj obj = HealthProj.parse(json); System.assert(obj != null); } }Salesforce is giving me a JSON Exception system error with the Boolean form:
' \"Active\": \"False\",'+
The full error message is System.JSONException: Illegal value for boolean: False at [line:1, column:421]
Class.System.JSON.deserialize: line 15, column 1
Class.HealthProj.parse: line 32, column 1
Class.HealthProj_Test.testParse: line 27, column 1
I've tried using
' \"Active\": \"0\",'+
with similar failure results.
All Answers
That doesn't compile. It generates an "Unexpected token '<'. at line 23 column 1"