On Wed, 28 Sep 2022, Hairy Pixels via fpc-pascal wrote:

Ok I narrowed down this bug I get with 3.2.2 to TJSONParser.
I’m so confused as to what changed.  FormatJSON prints the JSON as expected but 
AsString crashes and gives the error I was seeing from the RPC which it trapped 
as an exception. When it’s send across the RPC layer it must call AsString and 
then blow up thus giving me this error.

The JSON in question printed from FormatJSON is valid and can be opened in a 
JSON editor even so I know it’s ok.

===========================

Request := TJSONParser.Create(Content, DefaultOptions).Parse;

writeln(Request.FormatJSON);  // this prints the JSON correctly (Request 
ClassName is TJSONObject)

writeln(Request.AsString);
gives this error:

An unhandled exception occurred at $00000001050261A7:
EJSON: Cannot convert data from object value

Of course, as AsString will not work on a TJSONObject. AsString will only work on the simple types, not on the object or array types or null.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to