<p>IMHO, the <strong>TJSJSON</strong> external class definition is incorrect.</p>
<p>Currently, we have class function, if you want to use the stringify method, use this wierd way:<span style="line-height: 1.3;"> </span><strong><span style="line-height: 1.3;">TJSJSON.stringify( jsObject);</span></strong></p>
<p>I think code that don't have mutual dependencies should be separate in units:</p>
<!-- HTML generated using hilite.me -->
<div style="background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;">
<pre style="margin: 0; line-height: 125%;"><span style="color: #008800; font-weight: bold;">unit</span> ECMA<span style="color: #333333;">.</span>Json<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">interface</span>
<span style="color: #888888;">{$mode objfpc}</span>
<span style="color: #888888;">{$modeswitch externalclass}</span>
<span style="color: #008800; font-weight: bold;">type</span>
TKeyValueProcessor <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">function</span> (Key<span style="color: #333333;">:</span> <span style="color: #008800; font-weight: bold;">String</span><span style="color: #333333;">;</span> Value<span style="color: #333333;">:</span> JSValue)<span style="color: #333333;">:</span> JSValue<span style="color: #333333;">;</span>
JJSON <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">class</span> external name <span style="background-color: #fff0f0;">'JSON'</span>
<span style="color: #003388; font-weight: bold;">public</span>
<span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">parse</span>(Text<span style="color: #333333;">:</span> <span style="color: #008800; font-weight: bold;">String</span>)<span style="color: #333333;">:</span> JSValue<span style="color: #333333;">;</span> overload<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">parse</span>(Text<span style="color: #333333;">:</span> <span style="color: #008800; font-weight: bold;">String</span><span style="color: #333333;">;</span> Reviver<span style="color: #333333;">:</span> TKeyValueProcessor)<span style="color: #333333;">:</span> JSValue<span style="color: #333333;">;</span> overload<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">stringify</span>(<span style="color: #008800; font-weight: bold;">const</span> Value<span style="color: #333333;">:</span> JSValue)<span style="color: #333333;">:</span> <span style="color: #008800; font-weight: bold;">String</span><span style="color: #333333;">;</span> overload<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">stringify</span>(<span style="color: #008800; font-weight: bold;">const</span> Value<span style="color: #333333;">:</span> JSValue<span style="color: #333333;">;</span> Replacer<span style="color: #333333;">:</span> TKeyValueProcessor)<span style="color: #333333;">:</span> <span style="color: #008800; font-weight: bold;">String</span><span style="color: #333333;">;</span> overload<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">function</span> <span style="color: #0066bb; font-weight: bold;">stringify</span>(<span style="color: #008800; font-weight: bold;">const</span> Value<span style="color: #333333;">:</span> JSValue<span style="color: #333333;">;</span> Replacer<span style="color: #333333;">:</span> TKeyValueProcessor<span style="color: #333333;">;</span> Space<span style="color: #333333;">:</span> <span style="color: #008800; font-weight: bold;">String</span>)<span style="color: #333333;">:</span> <span style="color: #008800; font-weight: bold;">String</span><span style="color: #333333;">;</span> overload<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">end</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">var</span>
JSON<span style="color: #333333;">:</span> JJSON<span style="color: #333333;">;</span> external name <span style="background-color: #fff0f0;">'JSON'</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">implementation</span>
<span style="color: #008800; font-weight: bold;">end</span><span style="color: #333333;">.</span>
</pre>
</div>
<p>and use like this: <strong>JSON.stringify( JsonObject );</strong></p>
<br/><hr align="left" width="300" />
Sent from the <a href="http://free-pascal-general.1045716.n5.nabble.com/">Free Pascal - General mailing list archive</a> at Nabble.com.<br/>