[squeak-dev] CouchDB was: MySQL question?

Mike Hales mike.hales at kscape.com
Tue Jan 12 17:48:58 UTC 2010


For me, having it be ordered was only about testing. For example I wanted to
be able to simply have some test like:

test: aString

self assert: ( JsonObject readFrom: aString readStream ) printJson =
aString.

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.

Mike

Mike Hales
Engineering Manager
KnowledgeScape
www.kscape.com


On Tue, Jan 12, 2010 at 1:00 AM, Igor Stasenko <siguctua at gmail.com> wrote:

> 2010/1/12 Mike Hales <mike.hales at kscape.com>:
> > I made a Json parser in VisualWorks for our product, and I used an
> > OrderedDictionary, because I wanted to be able to parse json to a
> > JsonObject, then emit a json string back that would be equivalent. With a
> > Dictionary, the order would change, thus making the original and emitted
> > json strings different. Maybe that's why an OrderedCollection was used.
> > Mike
>
> I see. Can you tell, where it makes difference (except visual)?
> Is there something what depends on a specific key order?
>
> > Mike Hales
> > Engineering Manager
> > KnowledgeScape
> > www.kscape.com
> >
> >
> > On Mon, Jan 11, 2010 at 5:02 PM, Igor Stasenko <siguctua at gmail.com>
> wrote:
> >>
> >> 2010/1/12 Levente Uzonyi <leves at elte.hu>:
> >> > On Tue, 12 Jan 2010, Igor Stasenko wrote:
> >> >
> >> >> 2010/1/12 Mike Hales <mike.hales at kscape.com>:
> >> >>>>
> >> >>>>
> >> >>>> Or use better DB - CouchDB ;)
> >> >>>>
> >> >>> Igor, I noticed your CouchDB library on SqueakSource, but browsing
> >> >>> from
> >> >>> the
> >> >>> web interface it looked like a fork of the JSON libraries and I
> >> >>> couldn't
> >> >>> quite tell what was going on. What is the status of this? Is it done
> >> >>> and
> >> >>> is
> >> >>> there a tutorial?
> >> >>
> >> >> I forked the JSON library to not interfere with existing one.
> >> >> My main point of displeasure with original, is that JsonObject using
> a
> >> >> collection
> >> >> of key/value pairs , held in OrderedCollection,
> >> >> while in my implementation a JsonObject is a subclass of Dictionary,
> >> >> which makes accessing properties much faster.
> >> >
> >> > Older versions (up to JSON-ul.15) used a Dictionary. OrderedCollection
> >> > was a
> >> > bad idea performance-wise.
> >> >
> >> I'm not sure yet. It maybe better to use a dictionary ivar instead of
> >> subclassing a Dictionary.
> >> Because in some places i need to tell the difference between
> >> Dictionary and JsonObject
> >> because i want to be allow to serialize and deserialize arbitrary
> >> smalltalk objects as documents,
> >> including collections and dictionaries , of course.
> >> So, when deserializing, i need to determine somehow, what instance to
> >> create - a Dictionary or
> >> another JsonObject.
> >>
> >>
> >> >
> >> > Levente
> >> >
> >> >>
> >> >> Also, an original CouchDB package (
> http://www.squeaksource.com/CouchDB)
> >> >> using a curl plugin for speaking with database.
> >> >> While my implementation using a sockets, provided by squeak, which
> >> >> allows
> >> >> me
> >> >> to read the data in streaming mode, so i could start parsing a json
> >> >> document, even
> >> >> if its not fully retrieved yet i.e.:
> >> >>
> >> >> stream := (db streaming documentAt: '12345') readStream.
> >> >> json := Json readFrom: stream.
> >> >>
> >> >>> Mike
> >> >>
> >> >>
> >> >> --
> >> >> Best regards,
> >> >> Igor Stasenko AKA sig.
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Best regards,
> >> Igor Stasenko AKA sig.
> >>
> >
> >
> >
> >
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100112/6490aa67/attachment.htm


More information about the Squeak-dev mailing list