#1 2025-07-30 01:01:18

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 71
Website

JSON with dollar symbol ($) in the name

Hey ab,

SQLite accepts it, and many other validators accept JSON with names without double quotes and with the dollar symbol ($).
Shouldn't we accept it too?
For example:

  var s := '{item$one:1,item$two:1,item$three:1}';
  var dv: TDocVariantData;
  dv.InitJson(s);
  s := dv.ToJson;
 //the value of s is: '{"item":1,"item":1,"item":1}'

The change would be in the file mormot.core.json

if c in ['_', '0'..'9', 'a'..'z', 'A'..'Z', '.', '[', ']', '$'] then
include(JSON_CHARS[c], jcJsonIdentifier);

Could it be?

Offline

#2 2025-07-30 06:47:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,148
Website

Re: JSON with dollar symbol ($) in the name

Good idea!

Since '$' is already in jtIdentifierFirstChar and jcJsonIdentifierFirstChar, I guess we could add it to jcJsonIdentifier too.

Please try with
https://github.com/synopse/mORMot2/commit/aaf06cf8c

Offline

#3 2025-07-30 13:41:28

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 71
Website

Re: JSON with dollar symbol ($) in the name

Great
There's only one fix left (at least in Delphi 12).


[dcc32 Error] mormot.core.base.pas(9905): E2003 Undeclared identifier: 'GetCurrentThreadId'
[dcc32 Fatal Error] F2063 Could not compile used unit 'mormot.core.base.pas'

Offline

#4 2025-07-30 15:45:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,148
Website

Re: JSON with dollar symbol ($) in the name

Offline

Board footer

Powered by FluxBB