I have an interesting issue which appears to have changed in the latest RO SDK. My browser code passes in some JSON as one of the parameters. This usually gets passed through just fine, but now is being modified in some odd way in the current beta (well, last weeks).
The browser shows this as the body of the request. Note that the szPassword value is the one of interest.
It is getting a character of ordinal 16 (not sure if that is hex or dec, but neither is right) where the escaped quote used to be. I can’t find anything that shows it to be wrong in the general reading. If you can suggest somewhere to look, I’m happy to examine it.
Seems this has been a creeping feature. I have versions which output the lchar value, and the latest which appends the 22. Others have the WriteString which outputs a double quote for a 22, and others which don’t.
Regardless, this is a breaking change, and should be reversed in the latest version. JSON should be parsed as per the standard, and not using some odd variation to try to allow a double-quote in the quoted string. The standard says to use " as the value, not 22.
Hmm, I now find that the JSON being sent to my browser application is different too, and has the \u0022 codes embedded. I really would rather not have to update the javascript module that is on the web server. Can it not be processed properly?
I suggest that the wrong fix was made then! What is the normal way to pass a unicode character? As I have said, there appears to be older code to process a 22 character, so what is that doing?
I shall dig into this further tomorrow, but right now you have a change that breaks perfectly valid JSON, and breaks the normal RO SDK interface.
procedure WriteString(AStream: TStream; AValue: JSON_String);
// snip
var
i,j: integer;
s: string;
begin
WriteChar(AStream, '"');
for i := _StrLow to _StrHigh(AValue) do begin
case ord(AValue[i]) of
22 {"} : WriteTag('"');
92 {\} : WriteTag('\');
Okay, this is the wrong part. The 22 is the HEX version of the double-quote, and the Ordinal Decimal should be 34. So what is happening is that the code is converting the wrong character. I presume that the read is then wrong too. But fixing the read is breaking the rest of the code.
Running version 9.4.0.1355 I ran into this again today. The quotation mark (") gets read as decimal 22.
In the uROJsonParser file I propose this fix after running a number of tests here.
In procedure WriteString(AStream: TStream; AValue: JSON_String);
In the case statement change 22 {"} : WriteTag('"');
to: 34 {"} : WriteTag('"');
and in function ReadString(AStream: TStream):JSON_String;
in the while loop change else if lchar = '"' then Result := Result + JSON_Char(#22)
to: else if lchar = '"' then Result := Result + JSON_Char(#34)
You nailed that on the head. I somehow had Delphi pointing to a source folder for .1337 even though I had .1355 installed. It works correctly after pointing it to the .1355 source.