@@ -3997,6 +3997,41 @@ public void testStrictModeJSONTokener_expectException(){
39973997 assertThrows (JSONException .class , () -> { new JSONObject (tokener ); });
39983998 }
39993999
4000+ @ Test
4001+ public void test_strictModeWithMisCasedBooleanValue (){
4002+ JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration ().withStrictMode ();
4003+
4004+ try {
4005+ JSONObject j1 = new JSONObject ("{\" a\" :True}" , jsonParserConfiguration );
4006+ fail ("Expected an exception" );
4007+ } catch (JSONException e ) { }
4008+ try {
4009+ JSONObject j2 = new JSONObject ("{\" a\" :TRUE}" , jsonParserConfiguration );
4010+ fail ("Expected an exception" );
4011+ } catch (JSONException e ) { }
4012+ }
4013+
4014+ @ Test
4015+ public void test_strictModeWithInappropriateKey (){
4016+ JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration ().withStrictMode ();
4017+
4018+ // Parsing the following objects should fail
4019+ try {
4020+ JSONObject j3 = new JSONObject ("{true : 3}" , jsonParserConfiguration );
4021+ fail ("Expected an exception" );
4022+ } catch (JSONException e ) { }
4023+ try {
4024+ JSONObject j4 = new JSONObject ("{TRUE : 3}" , jsonParserConfiguration );
4025+ fail ("Expected an exception" );
4026+ } catch (JSONException e ) { }
4027+ try {
4028+ JSONObject j5 = new JSONObject ("{1 : 3}" , jsonParserConfiguration );
4029+ fail ("Expected an exception" );
4030+ } catch (JSONException e ) { }
4031+
4032+ }
4033+
4034+
40004035 /**
40014036 * Method to build nested map of max maxDepth
40024037 *
0 commit comments