function JsonTest::testReversibility
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testReversibility()
- 8.9.x core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testReversibility()
- 10 core/tests/Drupal/Tests/Component/Serialization/JsonTest.php \Drupal\Tests\Component\Serialization\JsonTest::testReversibility()
Tests converting PHP variables to JSON strings and back.
File
-
core/
tests/ Drupal/ Tests/ Component/ Serialization/ JsonTest.php, line 92
Class
- JsonTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Serialization%21Json.php/class/Json/11.x" title="Default serialization for JSON." class="local">\Drupal\Component\Serialization\Json</a> @group Serialization
Namespace
Drupal\Tests\Component\SerializationCode
public function testReversibility() : void {
$json = Json::encode($this->string);
// Verify that encoding/decoding is reversible.
$json_decoded = Json::decode($json);
$this->assertSame($this->string, $json_decoded, 'Encoding a string to JSON and decoding back results in the original string.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.