@@ -356,10 +356,10 @@ public function testToJsonString10() {
356356 . ' "obj":{ ' ."\r\n"
357357 . ' }, ' ."\r\n"
358358 . ' "general":{ ' ."\r\n"
359- . ' "property00 ":"1", ' ."\r\n"
360- . ' "property01 ":"3", ' ."\r\n"
361- . ' "property02 ":99, ' ."\r\n"
362- . ' "property04 ":"ok" ' ."\r\n"
359+ . ' "property_00 ":"1", ' ."\r\n"
360+ . ' "property_01 ":"3", ' ."\r\n"
361+ . ' "property_02 ":99, ' ."\r\n"
362+ . ' "property_04 ":"ok" ' ."\r\n"
363363 . ' } ' ."\r\n"
364364 . ' }, ' ."\r\n"
365365 . ' "o":{ ' ."\r\n"
@@ -369,7 +369,7 @@ public function testToJsonString10() {
369369 . ' } ' ."\r\n"
370370 . '} ' ,$ j .'' );
371371 $ j ->setIsFormatted (false );
372- $ this ->assertEquals ('{"jsonx":{"number_one":1,"arr":[],"obj":{},"general":{"property00 ":"1","property01 ":"3","property02 ":99,"property04 ":"ok"}},"o":{"property_00":"1","property_01":2,"property_02":3}} ' ,$ j .'' );
372+ $ this ->assertEquals ('{"jsonx":{"number_one":1,"arr":[],"obj":{},"general":{"property_00 ":"1","property_01 ":"3","property_02 ":99,"property_04 ":"ok"}},"o":{"property_00":"1","property_01":2,"property_02":3}} ' ,$ j .'' );
373373 return $ j ;
374374 }
375375 /**
@@ -390,16 +390,16 @@ public function testToJsonXString10(Json $json) {
390390 . ' <json:object name="obj"> ' ."\r\n"
391391 . ' </json:object> ' ."\r\n"
392392 . ' <json:object name="general"> ' ."\r\n"
393- . ' <json:string name="property00 "> ' ."\r\n"
393+ . ' <json:string name="property_00 "> ' ."\r\n"
394394 . ' 1 ' ."\r\n"
395395 . ' </json:string> ' ."\r\n"
396- . ' <json:string name="property01 "> ' ."\r\n"
396+ . ' <json:string name="property_01 "> ' ."\r\n"
397397 . ' 3 ' ."\r\n"
398398 . ' </json:string> ' ."\r\n"
399- . ' <json:number name="property02 "> ' ."\r\n"
399+ . ' <json:number name="property_02 "> ' ."\r\n"
400400 . ' 99 ' ."\r\n"
401401 . ' </json:number> ' ."\r\n"
402- . ' <json:string name="property04 "> ' ."\r\n"
402+ . ' <json:string name="property_04 "> ' ."\r\n"
403403 . ' ok ' ."\r\n"
404404 . ' </json:string> ' ."\r\n"
405405 . ' </json:object> ' ."\r\n"
@@ -445,6 +445,35 @@ public function testToJsonString11() {
445445 . '"3":{"Property00":"1","Property01":2,"Property02":3,"Property04":5},"4":{"good":true}},"1":{"bad":false}}} ' ,$ json .'' );
446446 return $ json ;
447447 }
448+ /**
449+ * @test
450+ */
451+ public function testToJsonString12 () {
452+ $ j = new Json ([
453+ '123_56_oKo ' => 5 ,
454+ 'hell-55-o-p-P-x ' => 'Ok '
455+ ]);
456+ $ this ->assertEquals ('{"123_56_oKo":5,"hell-55-o-p-P-x":"Ok"} ' , $ j ->toJSONString ());
457+ $ j ->setPropsStyle ('snake ' );
458+ $ this ->assertEquals ('{"123_56_o_ko":5,"hell_55_o_p_p_x":"Ok"} ' , $ j ->toJSONString ());
459+ $ j ->setPropsStyle ('kebab ' );
460+ $ this ->assertEquals ('{"123-56-o-ko":5,"hell-55-o-p-p-x":"Ok"} ' , $ j ->toJSONString ());
461+ }
462+ /**
463+ * @test
464+ */
465+ public function testToJsonString13 () {
466+ $ j = new Json ([
467+ '_123_56_oKo ' => 5 ,
468+ 'hell-55-o-p-P-x ' => 'Ok '
469+ ]);
470+ $ this ->assertEquals ('{"_123_56_oKo":5,"hell-55-o-p-P-x":"Ok"} ' , $ j ->toJSONString ());
471+ $ j ->setPropsStyle ('kebab ' );
472+ $ this ->assertEquals ('{"-123-56-o-ko":5,"hell-55-o-p-p-x":"Ok"} ' , $ j ->toJSONString ());
473+ $ j ->setPropsStyle ('snake ' );
474+ $ this ->assertEquals ('{"_123_56_o_ko":5,"hell_55_o_p_p_x":"Ok"} ' , $ j ->toJSONString ());
475+
476+ }
448477 /**
449478 * @depends testToJsonString11
450479 * @param Json $json
0 commit comments