Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-01

PAS2JS: JSON suggestion

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

warleyalex

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 );