Forum > Packages and Libraries

TSimpleJSONExporter

(1/1)

zyzmo:
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!

mike_p:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  S:= 'null'line 229 ->
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  S:= 'true'line 231 ->
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  S:= 'false';lines 242-244 should be removed leaving just
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- FCurrentRow:=FCurrentRow+', ';lines 259-261 should be removed leaving just
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- 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:
I posted a bug report: https://gitlab.com/freepascal.org/fpc/source/-/issues/39460

[EDIT]
Already fixed in fpc/main...

mike_p:
Hey Werner! - perfect response! And amazingly already taken up and applied by Michael Van Canneyt!
Very impressive.

Navigation

[0] Message Index

Go to full version