Skip to content

Commit

Permalink
Merge pull request #16 from microsoft/dev
Browse files Browse the repository at this point in the history
Release 0.4.1
  • Loading branch information
Ndiritu authored Mar 6, 2023
2 parents 9044dd6 + 042b711 commit 81a18e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/JsonSerializationWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/JsonSerializationWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 81a18e3

Please sign in to comment.