Recent

Author Topic: generate JSON and strange char  (Read 3132 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: generate JSON and strange char
« Reply #15 on: July 12, 2024, 09:41:34 am »
yes I missed that. but I test json with my own json code. no excuse in this case.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

jcmontherock

  • Sr. Member
  • ****
  • Posts: 338
Re: generate JSON and strange char
« Reply #16 on: July 12, 2024, 10:23:05 am »
ecma-262 tells that json script should be in utf-16 encoded and RFC8259 in utf-8 !... In summary it seems that we can use both !...
Windows 11 UTF8-64 - Lazarus 4.4-64 - FPC 3.2.2

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: generate JSON and strange char
« Reply #17 on: July 12, 2024, 11:23:19 am »
As long as you escape correctly, probably yes.
But I wonder what they have been smoking while basically re-defining a standard.
That is an absolute no-no in engineering circles.
The latest on sqlite.org is obviously written with a wry sense of humor.....
Read it twice and you will get the joke... %) if you knew about the utf16 part...
JSON is supposed to be a subset of ECMAscript and that is still utf16.
The wry humor comes likely from https://en.wikipedia.org/wiki/Douglas_Crockford himself.
« Last Edit: July 12, 2024, 11:43:35 am by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

BrunoK

  • Hero Member
  • *****
  • Posts: 766
  • Retired programmer
Re: generate JSON and strange char
« Reply #18 on: July 12, 2024, 12:28:48 pm »
Hello,

I've a code for generate json from my data like this:

Code: Pascal  [Select][+][-]
  1. .
  2. .
  3. .
  4. //      JSONString := JSON_Main.FormatJSON; replace with
  5.      JSONString := JSON_Main.AsJSON;  // No carriage returns thus no trouble with LineEnding.
  6. .
  7. .
  8. .
  9.  

watching in  JSONString i found:


ANSISTRING($00007F8A8734A358)^: '{'#$0A'  "query_11" : {'#$0A'    "ServerElement" : {'#$0A'      "FHost" : "192.168.17.51",'#$0A'      "FPort" : 5432,'#$0A'     ,'#$0A'      "FInitialDatabase" : "postgres"'#$0A'    },'#$0A'    "database" : "asda",'#$0A'    "queryBody" : "c2VsZWN0ICogZnJvbSB0ZXJtaW5hbGkK"'#$0A'  }'#$0A'}'

why do I find those characters like ''#$0A' '?
Because JSON_Main.FormatJSON; returns a readable from of JSON stream.

BrunoK

  • Hero Member
  • *****
  • Posts: 766
  • Retired programmer
Re: generate JSON and strange char
« Reply #19 on: July 12, 2024, 01:48:28 pm »
Actually, fairly good basic use description of fpjson can be found in the Wiki at https://wiki.freepascal.org/fcl-json

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: generate JSON and strange char
« Reply #20 on: July 12, 2024, 01:52:25 pm »
NO json.org is the only source. The rest is derived.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

BrunoK

  • Hero Member
  • *****
  • Posts: 766
  • Retired programmer
Re: generate JSON and strange char
« Reply #21 on: July 12, 2024, 03:18:23 pm »
Actually, fairly good basic use description of fpjson can be found in the Wiki at https://wiki.freepascal.org/fcl-json

This topic was initially about using fpjson in Free Pascal and why there were CR LF in the JSON string.

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: generate JSON and strange char
« Reply #22 on: July 12, 2024, 04:11:44 pm »
I am aware of that. read my answer better and look at json.org, which you obviously did not: it needs to be escaped. Period.
Next time, check the source. Not the sourcecode but who wrote the specs.
« Last Edit: July 12, 2024, 04:13:31 pm by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

BrunoK

  • Hero Member
  • *****
  • Posts: 766
  • Retired programmer
Re: generate JSON and strange char
« Reply #23 on: July 12, 2024, 04:38:12 pm »
I am aware of that. read my answer better and look at json.org, which you obviously did not: it needs to be escaped. Period.
Next time, check the source. Not the sourcecode but who wrote the specs.
On s'en fout.

bytebites

  • Hero Member
  • *****
  • Posts: 778
Re: generate JSON and strange char
« Reply #24 on: July 12, 2024, 05:42:09 pm »
And the piece of code that was claimed to be Thaddys was not his originally.

Thaddy

  • Hero Member
  • *****
  • Posts: 18764
  • To Europe: simply sell USA bonds: dollar collapses
Re: generate JSON and strange char
« Reply #25 on: July 12, 2024, 06:14:40 pm »
I did not claim that code. Maybe you are refering to the wrong subject?
Because I know what I wrote.(that is except when Benny remembers me that I wrote it)
Yes, I used goto, mea culpa...and that code was written originally in turbo basic and more than 40 35 years old.
God bless, your soul, Bob Zale, I still miss you my mentor and guru.
« Last Edit: July 12, 2024, 06:31:07 pm by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

 

TinyPortal © 2005-2018