Skip to content

Conversation

pamoller
Copy link
Contributor

Transforming JSON documents to XML document to use with XPath causes a loss of information, cause the string operator translates true and null to ''

 $subNode->nodeValue = htmlspecialchars((string)$value);

So boolean values can't be found by an expression like:

$I->seeResponseJsonXpathEvaluatesTo("//boolean[text() = 'true']");

Using a more elaborated transformation, https://tqdev.com/2017-converting-json-to-xml-in-javascript-and-php, keeps all informations:

{"boolean":true, "number": -1.2780E+2, "null": null, "string": "i'am a sentence"}

transforms to now

<root>
   <boolean type="boolean">true</boolean>
   <number type ="number">-127.8</number>
   <null type="null"></null>
   <string type="string">i'am a sentence</string>
</root>

so see now: JsonArrayTest.php

@pamoller
Copy link
Contributor Author

I hope, this fits the needs :)

@Naktibalda Naktibalda merged commit 57b35f9 into Codeception:master Aug 22, 2022
@Naktibalda
Copy link
Member

Released as 3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants