[fpc-pascal] PAS2JS: JSON suggestion

warleyalex warleyalex at yahoo.com.br
Thu Jan 11 13:39:23 CET 2018


IMHO, the TJSJSON external class definition is incorrect.
Currently, we have class function, if you want to use the stringify method,
use this wierd way: TJSJSON.stringify( jsObject);
I think code that don't have mutual dependencies should be separate in
units:
unit ECMA.Json;interface{$mode objfpc}{$modeswitch externalclass}type 
TKeyValueProcessor = function (Key: String; Value: JSValue): JSValue;  
JJSON = class external name 'JSON'  public    function parse(Text: String):
JSValue; overload;    function parse(Text: String; Reviver:
TKeyValueProcessor): JSValue; overload;    function stringify(const Value:
JSValue): String; overload;    function stringify(const Value: JSValue;
Replacer: TKeyValueProcessor): String; overload;    function stringify(const
Value: JSValue; Replacer: TKeyValueProcessor; Space: String): String;
overload;  end;var  JSON: JJSON; external name 'JSON';implementationend.
and use like this: JSON.stringify( JsonObject );




--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180111/af48f68f/attachment.html>


More information about the fpc-pascal mailing list