[fpc-pascal] JSONStringToString question

Michael Van Canneyt michael at freepascal.org
Sun Mar 14 00:43:08 CET 2021



On Sat, 13 Mar 2021, Bart via fpc-pascal wrote:

> From : https://www.freepascal.org/docs-html/current/fcl/fpjson/jsonstringtostring.html
>
> Function result
> Pascal string with escaped characters replaced
>
> {$mode objfpc}
> {$h+}
> uses
>  fpjson;
>
> var
>    S1, S2: TJSONStringType;
> begin
>  repeat
>    write('S: ');readln(S2);
>    S1 := JSONStringToString(S2);
>    writeln(S1);
>  until S2='';
> end.
>
> C:\Users\Bart\LazarusProjecten\ConsoleProjecten>fpc test.pas
> Free Pascal Compiler version 3.2.0 [2020/06/04] for i386
> Copyright (c) 1993-2020 by Florian Klaempfl and others
> Target OS: Win32 for i386
> Compiling test.pas
> Linking test.exe
> 15 lines compiled, 0.2 sec, 233536 bytes code, 10196 bytes data
>
> C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test
> S: \u0041\
> A (as expected)
> S: \u0042
> B (as expected)
> S: \"\u0041\
> "A (as expected)
> S: \"\u0041\"
> "A" (as expected)
> S: \u0041\u0042
> AAB (Huh??)
>
> Do I misunderstand the purpose of this function or is this a bug?

Seems like a bug.

Michael.


More information about the fpc-pascal mailing list