* Namespaced fcl-json

This commit is contained in:
Michaël Van Canneyt 2023-11-26 21:10:52 +01:00
parent eab8c5f3af
commit 8b9c9cd5d6
4 changed files with 34 additions and 13 deletions

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit FpJson.Data;
{$include ../src/fpjson.pp}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit FpJson.JS;
{$include ../src/fpjsonjs.pas}

View File

@ -12,22 +12,21 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{$IFNDEF FPC_DOTTEDUNITS}
unit fpjson;
{$ENDIF}
{$mode objfpc}
{$h+}
unit fpjson;
interface
uses
{$IFNDEF PAS2JS}
variants,
{$ENDIF}
{$IFDEF PAS2JS}
JS, RTLConsts, Types,
{$ENDIF}
SysUtils,
classes,
contnrs;
{$IFDEF FPC_DOTTEDUNITS}
JSApi.JS, System.RTLConsts, System.Types, System.SysUtils, System.Classes, System.Contnrs;
{$ELSE}
JS, RTLConsts, Types, SysUtils, classes, contnrs;
{$EnDIF}
type
TJSONtype = (jtUnknown, jtNumber, jtString, jtBoolean, jtNull, jtArray, jtObject);
@ -798,7 +797,12 @@ Function GetJSONStringParserHandler: TJSONStringParserHandler;
implementation
Uses typinfo;
Uses
{$IFDEF FPC_DOTTEDUNITS}
System.Typinfo;
{$ELSE}
typinfo;
{$ENDIF}
Resourcestring
SErrCannotConvertFromNull = 'Cannot convert data from Null value';
@ -1906,7 +1910,7 @@ end;
function TJSONNull.GetValue: TJSONVariant;
begin
Result:={$IFDEF PAS2JS}js.Null{$else}variants.Null{$ENDIF};
Result:={$IFDEF PAS2JS}{$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.Null{$else}variants.Null{$ENDIF};
end;
procedure TJSONNull.SetValue(const AValue: TJSONVariant);

View File

@ -12,14 +12,20 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{$IFNDEF FPC_DOTTEDUNITS}
unit fpjsonjs;
{$ENDIF}
{$mode objfpc}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.Types, FpJson.Data;
{$ELSE}
Classes, Types, fpjson;
{$ENDIF}
Function JSValueToJSONData(aValue : JSValue) : TJSONData;
Procedure HookGetJSONCallBack;
@ -27,7 +33,12 @@ Procedure UnHookGetJSONCallBack;
implementation
Uses JS;
Uses
{$IFDEF FPC_DOTTEDUNITS}
JSApi.JS;
{$ELSE}
JS;
{$ENDIF}
function JSValueToJSONData(aValue: JSValue): TJSONData;