Recent

Author Topic: TSimpleJSONExporter  (Read 2928 times)

zyzmo

  • New Member
  • *
  • Posts: 41
    • My Website
TSimpleJSONExporter
« on: August 05, 2019, 08:34:46 pm »
Hello!
I was implementing a solution using TSimpleJSONExporter, where I export a query to JSON and then send it through the internet. Although I noticed something weird, and I couldn't find an explanation... when I export the query as JSON, the separator of each field should be ',' but I get ';'

Eg.:
[{ "ID": 1; "NAME": "JOE DOE"}] instead of [{ "ID": 1, "NAME": "JOE DOE"}]

I tried to change the column format, but didn't work!

Thanks in advance!
<!-- Requirement Engineer -->

mike_p

  • New Member
  • *
  • Posts: 16
Re: TSimpleJSONExporter
« Reply #1 on: December 01, 2021, 08:35:06 am »
Okay, okay, yes it's a very old topic, but it's an even older bug!

I can confirm that the  TSimpleJSONExporter uses the wrong separator!

It also uses badly formed tokens for true, false and null. The json standard defines those tokens in lower case.

Fixes:
line 225 ->
Code: Pascal  [Select][+][-]
  1.   S:= 'null'
line 229 ->
Code: Pascal  [Select][+][-]
  1.   S:= 'true'
line 231 ->
Code: Pascal  [Select][+][-]
  1.   S:= 'false';
lines 242-244 should be removed leaving just
Code: Pascal  [Select][+][-]
  1.  FCurrentRow:=FCurrentRow+', ';
lines 259-261 should be removed leaving just
Code: Pascal  [Select][+][-]
  1.  FCurrentRow:=FCurrentRow+', ';

I don't have a gitlab account so it would be good if someone could make these changes.

for those that want a local change on windows, rebuilding fpc can be a real hassle, so I recommend:
1. Create a new project
2. Copy C:\lazarus\fpc\3.2.0\source\packages\fcl-db\src\export\fpsimplejsonexport.pp into your project directory
3. Add it to your project
4. Compile your project
5. Copy fpsimplejsonexport.o, fpsimplejsonexport.ppu, fpsimplejsonexport.rsj into C:\lazarus\fpc\3.2.0\units\x86_64-win64\fcl-db

wp

  • Hero Member
  • *****
  • Posts: 9178
Re: TSimpleJSONExporter
« Reply #2 on: December 01, 2021, 12:20:12 pm »
I posted a bug report: https://gitlab.com/freepascal.org/fpc/source/-/issues/39460

[EDIT]
Already fixed in fpc/main...
« Last Edit: December 01, 2021, 01:36:02 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

mike_p

  • New Member
  • *
  • Posts: 16
Re: TSimpleJSONExporter
« Reply #3 on: December 01, 2021, 05:22:30 pm »
Hey Werner! - perfect response! And amazingly already taken up and applied by Michael Van Canneyt!
Very impressive.

 

TinyPortal © 2005-2018