diff --git a/src/JsonSerializationWriter.php b/src/JsonSerializationWriter.php index b9fe461..01d0170 100644 --- a/src/JsonSerializationWriter.php +++ b/src/JsonSerializationWriter.php @@ -45,7 +45,7 @@ private function writePropertyName(string $propertyName): void { */ public function writeStringValue(?string $key, ?string $value): void { - $propertyValue = $value !== null ? '"'.addcslashes($value, "\\\r\n\"").'"' : ''; + $propertyValue = $value !== null ? '"'.addcslashes($value, "\\\r\n\"\t").'"' : ''; if ($value !== null) { if (!empty($key)) { $this->writePropertyName($key); diff --git a/tests/JsonSerializationWriterTest.php b/tests/JsonSerializationWriterTest.php index 65b8c9c..facfcce 100644 --- a/tests/JsonSerializationWriterTest.php +++ b/tests/JsonSerializationWriterTest.php @@ -201,8 +201,8 @@ public function testGetSerializedContent(): void{ */ public function testWriteStringValue(): void { $this->jsonSerializationWriter = new JsonSerializationWriter(); - $this->jsonSerializationWriter->writeAnyValue("statement", "This is a string"); - $expected = '"statement":"This is a string"'; + $this->jsonSerializationWriter->writeAnyValue("statement", "This is a string\n\r\t"); + $expected = '"statement":"This is a string\\n\\r\\t"'; $actual = $this->jsonSerializationWriter->getSerializedContent()->getContents(); $this->assertEquals($expected, $actual); }