For me, having it be ordered was only about testing. For example I wanted to be able to simply have some test like:<br><br>test: aString<br><br>self assert: ( JsonObject readFrom: aString readStream ) printJson = aString.<br>
<br>That dramatically simplified my testing of all my objects that needed to serialize to Json. Having the underlying JsonObject preserve order made that work. Having the internal representation be ordered is not incorrect, but could encourage others to rely on the order, which is incorrect. Semantically, the correct way to preserve order is to use an array element, not key value pairs. So using a Dictionary, rather than an OrderedCollection or OrderedSet should be fine.<br>
<br>Mike<br><br clear="all">Mike Hales<br>Engineering Manager<br>KnowledgeScape<br><a href="http://www.kscape.com">www.kscape.com</a><br>
<br><br><div class="gmail_quote">On Tue, Jan 12, 2010 at 1:00 AM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">2010/1/12 Mike Hales &lt;<a href="mailto:mike.hales@kscape.com">mike.hales@kscape.com</a>&gt;:<br>
</div><div class="im">&gt; I made a Json parser in VisualWorks for our product, and I used an<br>
&gt; OrderedDictionary, because I wanted to be able to parse json to a<br>
&gt; JsonObject, then emit a json string back that would be equivalent. With a<br>
&gt; Dictionary, the order would change, thus making the original and emitted<br>
&gt; json strings different. Maybe that&#39;s why an OrderedCollection was used.<br>
&gt; Mike<br>
<br>
</div>I see. Can you tell, where it makes difference (except visual)?<br>
Is there something what depends on a specific key order?<br>
<div><div></div><div class="h5"><br>
&gt; Mike Hales<br>
&gt; Engineering Manager<br>
&gt; KnowledgeScape<br>
&gt; <a href="http://www.kscape.com" target="_blank">www.kscape.com</a><br>
&gt;<br>
&gt;<br>
&gt; On Mon, Jan 11, 2010 at 5:02 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; 2010/1/12 Levente Uzonyi &lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;:<br>
&gt;&gt; &gt; On Tue, 12 Jan 2010, Igor Stasenko wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; 2010/1/12 Mike Hales &lt;<a href="mailto:mike.hales@kscape.com">mike.hales@kscape.com</a>&gt;:<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; Or use better DB - CouchDB ;)<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Igor, I noticed your CouchDB library on SqueakSource, but browsing<br>
&gt;&gt; &gt;&gt;&gt; from<br>
&gt;&gt; &gt;&gt;&gt; the<br>
&gt;&gt; &gt;&gt;&gt; web interface it looked like a fork of the JSON libraries and I<br>
&gt;&gt; &gt;&gt;&gt; couldn&#39;t<br>
&gt;&gt; &gt;&gt;&gt; quite tell what was going on. What is the status of this? Is it done<br>
&gt;&gt; &gt;&gt;&gt; and<br>
&gt;&gt; &gt;&gt;&gt; is<br>
&gt;&gt; &gt;&gt;&gt; there a tutorial?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; I forked the JSON library to not interfere with existing one.<br>
&gt;&gt; &gt;&gt; My main point of displeasure with original, is that JsonObject using a<br>
&gt;&gt; &gt;&gt; collection<br>
&gt;&gt; &gt;&gt; of key/value pairs , held in OrderedCollection,<br>
&gt;&gt; &gt;&gt; while in my implementation a JsonObject is a subclass of Dictionary,<br>
&gt;&gt; &gt;&gt; which makes accessing properties much faster.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Older versions (up to JSON-ul.15) used a Dictionary. OrderedCollection<br>
&gt;&gt; &gt; was a<br>
&gt;&gt; &gt; bad idea performance-wise.<br>
&gt;&gt; &gt;<br>
&gt;&gt; I&#39;m not sure yet. It maybe better to use a dictionary ivar instead of<br>
&gt;&gt; subclassing a Dictionary.<br>
&gt;&gt; Because in some places i need to tell the difference between<br>
&gt;&gt; Dictionary and JsonObject<br>
&gt;&gt; because i want to be allow to serialize and deserialize arbitrary<br>
&gt;&gt; smalltalk objects as documents,<br>
&gt;&gt; including collections and dictionaries , of course.<br>
&gt;&gt; So, when deserializing, i need to determine somehow, what instance to<br>
&gt;&gt; create - a Dictionary or<br>
&gt;&gt; another JsonObject.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Levente<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Also, an original CouchDB package (<a href="http://www.squeaksource.com/CouchDB" target="_blank">http://www.squeaksource.com/CouchDB</a>)<br>
&gt;&gt; &gt;&gt; using a curl plugin for speaking with database.<br>
&gt;&gt; &gt;&gt; While my implementation using a sockets, provided by squeak, which<br>
&gt;&gt; &gt;&gt; allows<br>
&gt;&gt; &gt;&gt; me<br>
&gt;&gt; &gt;&gt; to read the data in streaming mode, so i could start parsing a json<br>
&gt;&gt; &gt;&gt; document, even<br>
&gt;&gt; &gt;&gt; if its not fully retrieved yet i.e.:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; stream := (db streaming documentAt: &#39;12345&#39;) readStream.<br>
&gt;&gt; &gt;&gt; json := Json readFrom: stream.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Mike<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; Best regards,<br>
&gt;&gt; &gt;&gt; Igor Stasenko AKA sig.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Best regards,<br>
&gt;&gt; Igor Stasenko AKA sig.<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br>