The echo proc can sometimes be deceptive in terms of representing strings, so I prefer to throw in the repr proc which makes sure to represent strings (and other objects) in a more clear way. See the output I get when I add the following lines to the example, representing both sides of the comparison:
echo repr(s)
echo repr("214.05 USD")
==>
0x105f5c0b8""214.05 USD""
0x105f1cf70"214.05 USD"
Through this representation we can see the strings are really not equal. Your %
proc formats the contents of the Price
tuple as a space separated string node, and the JSON pretty proc converts that string node to its JSON representation, which includes double quotes. Thus, to make the last comparison equal we need to write it like this:
echo s == ""214.05 USD""
Another possibility would be to write the comparison accessing the JsonNode.str
variant field, which avoids involving the mischievous pretty
:
echo (%(v)).str == "214.05 USD"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…